@@ -41,7 +41,7 @@ type Res = def::Res<ast::NodeId>;
4141
4242/// A field or associated item from self type suggested in case of resolution failure.
4343enum AssocSuggestion {
44- Field ,
44+ Field ( Span ) ,
4545 MethodWithSelf { called : bool } ,
4646 AssocFn { called : bool } ,
4747 AssocType ,
@@ -51,7 +51,7 @@ enum AssocSuggestion {
5151impl AssocSuggestion {
5252 fn action ( & self ) -> & ' static str {
5353 match self {
54- AssocSuggestion :: Field => "use the available field" ,
54+ AssocSuggestion :: Field ( _ ) => "use the available field" ,
5555 AssocSuggestion :: MethodWithSelf { called : true } => {
5656 "call the method with the fully-qualified path"
5757 }
@@ -670,7 +670,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
670670 _ => String :: new ( ) ,
671671 } ;
672672 match candidate {
673- AssocSuggestion :: Field => {
673+ AssocSuggestion :: Field ( field_span ) => {
674674 if self_is_available {
675675 err. span_suggestion_verbose (
676676 span. shrink_to_lo ( ) ,
@@ -679,7 +679,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
679679 Applicability :: MachineApplicable ,
680680 ) ;
681681 } else {
682- err. span_label ( span , "a field by this name exists in `Self`" ) ;
682+ err. span_label ( field_span , "a field by that name exists in `Self`" ) ;
683683 }
684684 }
685685 AssocSuggestion :: MethodWithSelf { called } if self_is_available => {
@@ -1715,11 +1715,11 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
17151715 resolution. full_res ( )
17161716 {
17171717 if let Some ( field_ids) = self . r . field_def_ids ( did) {
1718- if field_ids
1718+ if let Some ( field_id ) = field_ids
17191719 . iter ( )
1720- . any ( | & field_id| ident. name == self . r . tcx . item_name ( field_id) )
1720+ . find ( | & & field_id| ident. name == self . r . tcx . item_name ( field_id) )
17211721 {
1722- return Some ( AssocSuggestion :: Field ) ;
1722+ return Some ( AssocSuggestion :: Field ( self . r . def_span ( * field_id ) ) ) ;
17231723 }
17241724 }
17251725 }
0 commit comments