@@ -278,7 +278,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
278
278
// The qualname for a method is the trait name or name of the struct in an impl in
279
279
// which the method is declared in followed by the method's name.
280
280
let mut qualname = match ty:: impl_of_method ( & self . analysis . ty_cx ,
281
- ast_util:: local_def ( method. id ) ) {
281
+ ast_util:: local_def ( method. id ) ) {
282
282
Some ( impl_id) => match self . analysis . ty_cx . map . get ( impl_id. node ) {
283
283
NodeItem ( item) => {
284
284
scope_id = item. id ;
@@ -349,7 +349,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
349
349
. and_then ( |def_id| {
350
350
if match def_id {
351
351
ty:: MethodTraitItemId ( def_id) => {
352
- method . id != 0 && def_id. node == 0
352
+ def_id . node != 0 && def_id != ast_util :: local_def ( method . id )
353
353
}
354
354
ty:: TypeTraitItemId ( _) => false ,
355
355
} {
@@ -392,8 +392,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
392
392
}
393
393
394
394
fn process_trait_ref ( & mut self ,
395
- trait_ref : & ast:: TraitRef ,
396
- impl_id : Option < NodeId > ) {
395
+ trait_ref : & ast:: TraitRef ) {
397
396
match self . lookup_type_ref ( trait_ref. ref_id ) {
398
397
Some ( id) => {
399
398
let sub_span = self . span . sub_span_for_type_name ( trait_ref. path . span ) ;
@@ -402,14 +401,6 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
402
401
sub_span,
403
402
id,
404
403
self . cur_scope ) ;
405
- match impl_id {
406
- Some ( impl_id) => self . fmt . impl_str ( trait_ref. path . span ,
407
- sub_span,
408
- impl_id,
409
- id,
410
- self . cur_scope ) ,
411
- None => ( ) ,
412
- }
413
404
visit:: walk_path ( self , & trait_ref. path ) ;
414
405
} ,
415
406
None => ( )
@@ -652,7 +643,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
652
643
trait_ref : & Option < ast:: TraitRef > ,
653
644
typ : & ast:: Ty ,
654
645
impl_items : & Vec < ast:: ImplItem > ) {
646
+ let trait_id = trait_ref. as_ref ( ) . and_then ( |tr| self . lookup_type_ref ( tr. ref_id ) ) ;
655
647
match typ. node {
648
+ // Common case impl for a struct or something basic.
656
649
ast:: TyPath ( ref path, id) => {
657
650
match self . lookup_type_ref ( id) {
658
651
Some ( id) => {
@@ -665,17 +658,29 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
665
658
self . fmt . impl_str ( path. span ,
666
659
sub_span,
667
660
item. id ,
668
- id,
661
+ Some ( id) ,
662
+ trait_id,
669
663
self . cur_scope ) ;
670
664
} ,
671
665
None => ( )
672
666
}
673
667
} ,
674
- _ => self . visit_ty ( & * typ) ,
668
+ _ => {
669
+ // Less useful case, impl for a compound type.
670
+ self . visit_ty ( & * typ) ;
671
+
672
+ let sub_span = self . span . sub_span_for_type_name ( typ. span ) ;
673
+ self . fmt . impl_str ( typ. span ,
674
+ sub_span,
675
+ item. id ,
676
+ None ,
677
+ trait_id,
678
+ self . cur_scope ) ;
679
+ }
675
680
}
676
681
677
682
match * trait_ref {
678
- Some ( ref trait_ref) => self . process_trait_ref ( trait_ref, Some ( item . id ) ) ,
683
+ Some ( ref trait_ref) => self . process_trait_ref ( trait_ref) ,
679
684
None => ( ) ,
680
685
}
681
686
@@ -1076,7 +1081,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
1076
1081
for param in generics. ty_params . iter ( ) {
1077
1082
for bound in param. bounds . iter ( ) {
1078
1083
if let ast:: TraitTyParamBound ( ref trait_ref, _) = * bound {
1079
- self . process_trait_ref ( & trait_ref. trait_ref , None ) ;
1084
+ self . process_trait_ref ( & trait_ref. trait_ref ) ;
1080
1085
}
1081
1086
}
1082
1087
if let Some ( ref ty) = param. default {
0 commit comments