@@ -41,7 +41,7 @@ type Res = def::Res<ast::NodeId>;
41
41
42
42
/// A field or associated item from self type suggested in case of resolution failure.
43
43
enum AssocSuggestion {
44
- Field ,
44
+ Field ( Span ) ,
45
45
MethodWithSelf { called : bool } ,
46
46
AssocFn { called : bool } ,
47
47
AssocType ,
@@ -51,7 +51,7 @@ enum AssocSuggestion {
51
51
impl AssocSuggestion {
52
52
fn action ( & self ) -> & ' static str {
53
53
match self {
54
- AssocSuggestion :: Field => "use the available field" ,
54
+ AssocSuggestion :: Field ( _ ) => "use the available field" ,
55
55
AssocSuggestion :: MethodWithSelf { called : true } => {
56
56
"call the method with the fully-qualified path"
57
57
}
@@ -670,7 +670,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
670
670
_ => String :: new ( ) ,
671
671
} ;
672
672
match candidate {
673
- AssocSuggestion :: Field => {
673
+ AssocSuggestion :: Field ( field_span ) => {
674
674
if self_is_available {
675
675
err. span_suggestion_verbose (
676
676
span. shrink_to_lo ( ) ,
@@ -679,7 +679,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
679
679
Applicability :: MachineApplicable ,
680
680
) ;
681
681
} 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`" ) ;
683
683
}
684
684
}
685
685
AssocSuggestion :: MethodWithSelf { called } if self_is_available => {
@@ -1715,11 +1715,11 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
1715
1715
resolution. full_res ( )
1716
1716
{
1717
1717
if let Some ( field_ids) = self . r . field_def_ids ( did) {
1718
- if field_ids
1718
+ if let Some ( field_id ) = field_ids
1719
1719
. 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) )
1721
1721
{
1722
- return Some ( AssocSuggestion :: Field ) ;
1722
+ return Some ( AssocSuggestion :: Field ( self . r . def_span ( * field_id ) ) ) ;
1723
1723
}
1724
1724
}
1725
1725
}
0 commit comments