File tree Expand file tree Collapse file tree 2 files changed +97
-1
lines changed
Expand file tree Collapse file tree 2 files changed +97
-1
lines changed Original file line number Diff line number Diff line change @@ -3628,16 +3628,41 @@ impl Impl {
36283628 . filter ( filter) ,
36293629 ) ;
36303630 }
3631+
3632+ if let Some ( block) =
3633+ ty. adt_id ( Interner ) . and_then ( |def| def. 0 . module ( db. upcast ( ) ) . containing_block ( ) )
3634+ {
3635+ if let Some ( inherent_impls) = db. inherent_impls_in_block ( block) {
3636+ all. extend (
3637+ inherent_impls. for_self_ty ( & ty) . iter ( ) . cloned ( ) . map ( Self :: from) . filter ( filter) ,
3638+ ) ;
3639+ }
3640+ if let Some ( trait_impls) = db. trait_impls_in_block ( block) {
3641+ all. extend (
3642+ trait_impls
3643+ . for_self_ty_without_blanket_impls ( fp)
3644+ . map ( Self :: from)
3645+ . filter ( filter) ,
3646+ ) ;
3647+ }
3648+ }
3649+
36313650 all
36323651 }
36333652
36343653 pub fn all_for_trait ( db : & dyn HirDatabase , trait_ : Trait ) -> Vec < Impl > {
3635- let krate = trait_. module ( db) . krate ( ) ;
3654+ let module = trait_. module ( db) ;
3655+ let krate = module. krate ( ) ;
36363656 let mut all = Vec :: new ( ) ;
36373657 for Crate { id } in krate. transitive_reverse_dependencies ( db) {
36383658 let impls = db. trait_impls_in_crate ( id) ;
36393659 all. extend ( impls. for_trait ( trait_. id ) . map ( Self :: from) )
36403660 }
3661+ if let Some ( block) = module. id . containing_block ( ) {
3662+ if let Some ( trait_impls) = db. trait_impls_in_block ( block) {
3663+ all. extend ( trait_impls. for_trait ( trait_. id ) . map ( Self :: from) ) ;
3664+ }
3665+ }
36413666 all
36423667 }
36433668
Original file line number Diff line number Diff line change @@ -337,6 +337,77 @@ impl Tr for S {
337337 const C: usize = 4;
338338 //^
339339}
340+ "# ,
341+ ) ;
342+ }
343+
344+ #[ test]
345+ fn goto_adt_implementation_inside_block ( ) {
346+ check (
347+ r#"
348+ //- minicore: copy, derive
349+ trait Bar {}
350+
351+ fn test() {
352+ #[derive(Copy)]
353+ //^^^^^^^^^^^^^^^
354+ struct Foo$0;
355+
356+ impl Foo {}
357+ //^^^
358+
359+ trait Baz {}
360+
361+ impl Bar for Foo {}
362+ //^^^
363+
364+ impl Baz for Foo {}
365+ //^^^
366+ }
367+ "# ,
368+ ) ;
369+ }
370+
371+ #[ test]
372+ fn goto_trait_implementation_inside_block ( ) {
373+ check (
374+ r#"
375+ struct Bar;
376+
377+ fn test() {
378+ trait Foo$0 {}
379+
380+ struct Baz;
381+
382+ impl Foo for Bar {}
383+ //^^^
384+
385+ impl Foo for Baz {}
386+ //^^^
387+ }
388+ "# ,
389+ ) ;
390+ check (
391+ r#"
392+ struct Bar;
393+
394+ fn test() {
395+ trait Foo {
396+ fn foo$0() {}
397+ }
398+
399+ struct Baz;
400+
401+ impl Foo for Bar {
402+ fn foo() {}
403+ //^^^
404+ }
405+
406+ impl Foo for Baz {
407+ fn foo() {}
408+ //^^^
409+ }
410+ }
340411"# ,
341412 ) ;
342413 }
You can’t perform that action at this time.
0 commit comments