@@ -643,28 +643,22 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
643643 if ns != Namespace :: ValueNS {
644644 return None ;
645645 }
646- debug ! ( "looking for variants or fields named {} for {:?}" , item_name, did) ;
646+ debug ! ( "looking for fields named {} for {:?}" , item_name, did) ;
647647 // FIXME: this doesn't really belong in `associated_item` (maybe `variant_field` is better?)
648- // NOTE: it's different from variant_field because it resolves fields and variants ,
648+ // NOTE: it's different from variant_field because it only resolves struct fields ,
649649 // not variant fields (2 path segments, not 3).
650650 let def = match tcx. type_of ( did) . kind ( ) {
651- ty:: Adt ( def, _) => def,
651+ ty:: Adt ( def, _) if !def . is_enum ( ) => def,
652652 _ => return None ,
653653 } ;
654- let field = if def. is_enum ( ) {
655- def. all_fields ( ) . find ( |item| item. ident . name == item_name)
656- } else {
657- def. non_enum_variant ( ) . fields . iter ( ) . find ( |item| item. ident . name == item_name)
658- } ?;
659- let kind = if def. is_enum ( ) { DefKind :: Variant } else { DefKind :: Field } ;
654+ let field = def. non_enum_variant ( ) . fields . iter ( ) . find ( |item| item. ident . name == item_name) ?;
660655 Some ( (
661656 root_res,
662657 format ! (
663- "{}.{}" ,
664- if def. is_enum( ) { "variant" } else { "structfield" } ,
658+ "structfield.{}" ,
665659 field. ident
666660 ) ,
667- Some ( ( kind , field. did ) ) ,
661+ Some ( ( DefKind :: Field , field. did ) ) ,
668662 ) )
669663 }
670664 Res :: Def ( DefKind :: Trait , did) => tcx
0 commit comments