@@ -643,28 +643,22 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
643
643
if ns != Namespace :: ValueNS {
644
644
return None ;
645
645
}
646
- debug ! ( "looking for variants or fields named {} for {:?}" , item_name, did) ;
646
+ debug ! ( "looking for fields named {} for {:?}" , item_name, did) ;
647
647
// 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 ,
649
649
// not variant fields (2 path segments, not 3).
650
650
let def = match tcx. type_of ( did) . kind ( ) {
651
- ty:: Adt ( def, _) => def,
651
+ ty:: Adt ( def, _) if !def . is_enum ( ) => def,
652
652
_ => return None ,
653
653
} ;
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) ?;
660
655
Some ( (
661
656
root_res,
662
657
format ! (
663
- "{}.{}" ,
664
- if def. is_enum( ) { "variant" } else { "structfield" } ,
658
+ "structfield.{}" ,
665
659
field. ident
666
660
) ,
667
- Some ( ( kind , field. did ) ) ,
661
+ Some ( ( DefKind :: Field , field. did ) ) ,
668
662
) )
669
663
}
670
664
Res :: Def ( DefKind :: Trait , did) => tcx
0 commit comments