@@ -278,7 +278,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
278278 // The qualname for a method is the trait name or name of the struct in an impl in
279279 // which the method is declared in followed by the method's name.
280280 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 ) ) {
282282 Some ( impl_id) => match self . analysis . ty_cx . map . get ( impl_id. node ) {
283283 NodeItem ( item) => {
284284 scope_id = item. id ;
@@ -349,7 +349,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
349349 . and_then ( |def_id| {
350350 if match def_id {
351351 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 )
353353 }
354354 ty:: TypeTraitItemId ( _) => false ,
355355 } {
@@ -392,8 +392,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
392392 }
393393
394394 fn process_trait_ref ( & mut self ,
395- trait_ref : & ast:: TraitRef ,
396- impl_id : Option < NodeId > ) {
395+ trait_ref : & ast:: TraitRef ) {
397396 match self . lookup_type_ref ( trait_ref. ref_id ) {
398397 Some ( id) => {
399398 let sub_span = self . span . sub_span_for_type_name ( trait_ref. path . span ) ;
@@ -402,14 +401,6 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
402401 sub_span,
403402 id,
404403 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- }
413404 visit:: walk_path ( self , & trait_ref. path ) ;
414405 } ,
415406 None => ( )
@@ -652,7 +643,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
652643 trait_ref : & Option < ast:: TraitRef > ,
653644 typ : & ast:: Ty ,
654645 impl_items : & Vec < ast:: ImplItem > ) {
646+ let trait_id = trait_ref. as_ref ( ) . and_then ( |tr| self . lookup_type_ref ( tr. ref_id ) ) ;
655647 match typ. node {
648+ // Common case impl for a struct or something basic.
656649 ast:: TyPath ( ref path, id) => {
657650 match self . lookup_type_ref ( id) {
658651 Some ( id) => {
@@ -665,17 +658,29 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
665658 self . fmt . impl_str ( path. span ,
666659 sub_span,
667660 item. id ,
668- id,
661+ Some ( id) ,
662+ trait_id,
669663 self . cur_scope ) ;
670664 } ,
671665 None => ( )
672666 }
673667 } ,
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+ }
675680 }
676681
677682 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) ,
679684 None => ( ) ,
680685 }
681686
@@ -1076,7 +1081,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
10761081 for param in generics. ty_params . iter ( ) {
10771082 for bound in param. bounds . iter ( ) {
10781083 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 ) ;
10801085 }
10811086 }
10821087 if let Some ( ref ty) = param. default {
0 commit comments