File tree Expand file tree Collapse file tree 9 files changed +60
-30
lines changed Expand file tree Collapse file tree 9 files changed +60
-30
lines changed Original file line number Diff line number Diff line change @@ -166,16 +166,18 @@ impl<'a> Resolver<'a> {
166166                let  self_is_available = self . self_value_is_available ( path[ 0 ] . ident . span ,  span) ; 
167167                match  candidate { 
168168                    AssocSuggestion :: Field  => { 
169-                         err. span_suggestion ( 
170-                             span, 
171-                             "try" , 
172-                             format ! ( "self.{}" ,  path_str) , 
173-                             Applicability :: MachineApplicable , 
174-                         ) ; 
175-                         if  !self_is_available { 
176-                             err. span_label ( span,  format ! ( "`self` value is a keyword \  
177-                                                           only available in \ 
178-                                                           methods with `self` parameter") ) ; 
169+                         if  self_is_available { 
170+                             err. span_suggestion ( 
171+                                 span, 
172+                                 "you might have meant to use the available field" , 
173+                                 format ! ( "self.{}" ,  path_str) , 
174+                                 Applicability :: MachineApplicable , 
175+                             ) ; 
176+                         }  else  { 
177+                             err. span_label ( 
178+                                 span, 
179+                                 "a field by this name exists in `Self`" , 
180+                             ) ; 
179181                        } 
180182                    } 
181183                    AssocSuggestion :: MethodWithSelf  if  self_is_available => { 
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ error[E0425]: cannot find value `meows` in this scope
22  --> $DIR/class-missing-self.rs:9:7
33   |
44LL |       meows += 1;
5-    |       ^^^^^ help: try : `self.meows`
5+    |       ^^^^^ help: you might have meant to use the available field : `self.meows`
66
77error[E0425]: cannot find function `sleep` in this scope
88  --> $DIR/class-missing-self.rs:10:7
Original file line number Diff line number Diff line change 1+ struct  A  { 
2+     banana :  u8 , 
3+ } 
4+ 
5+ impl  A  { 
6+     fn  new ( peach :  u8 )  -> A  { 
7+         A  { 
8+             banana :  banana //~ ERROR cannot find value `banana` in this scope 
9+         } 
10+     } 
11+ 
12+     fn  foo ( & self ,  peach :  u8 )  -> A  { 
13+         A  { 
14+             banana :  banana //~ ERROR cannot find value `banana` in this scope 
15+         } 
16+     } 
17+ } 
Original file line number Diff line number Diff line change 1+ error[E0425]: cannot find value `banana` in this scope
2+   --> $DIR/issue-60057.rs:8:21
3+    |
4+ LL |             banana: banana
5+    |                     ^^^^^^ a field by this name exists in `Self`
6+ 
7+ error[E0425]: cannot find value `banana` in this scope
8+   --> $DIR/issue-60057.rs:14:21
9+    |
10+ LL |             banana: banana
11+    |                     ^^^^^^ help: you might have meant to use the available field: `self.banana`
12+ 
13+ error[E0601]: `main` function not found in crate `issue_60057`
14+    |
15+    = note: consider adding a `main` function to `$DIR/issue-60057.rs`
16+ 
17+ error: aborting due to 3 previous errors
18+ 
19+ Some errors occurred: E0425, E0601.
20+ For more information about an error, try `rustc --explain E0425`.
Original file line number Diff line number Diff line change @@ -20,13 +20,13 @@ error[E0425]: cannot find value `x` in this scope
2020  --> $DIR/issue-14254.rs:30:9
2121   |
2222LL |         x;
23-    |         ^ help: try : `self.x`
23+    |         ^ help: you might have meant to use the available field : `self.x`
2424
2525error[E0425]: cannot find value `y` in this scope
2626  --> $DIR/issue-14254.rs:32:9
2727   |
2828LL |         y;
29-    |         ^ help: try : `self.y`
29+    |         ^ help: you might have meant to use the available field : `self.y`
3030
3131error[E0425]: cannot find value `a` in this scope
3232  --> $DIR/issue-14254.rs:34:9
@@ -56,13 +56,13 @@ error[E0425]: cannot find value `x` in this scope
5656  --> $DIR/issue-14254.rs:47:9
5757   |
5858LL |         x;
59-    |         ^ help: try : `self.x`
59+    |         ^ help: you might have meant to use the available field : `self.x`
6060
6161error[E0425]: cannot find value `y` in this scope
6262  --> $DIR/issue-14254.rs:49:9
6363   |
6464LL |         y;
65-    |         ^ help: try : `self.y`
65+    |         ^ help: you might have meant to use the available field : `self.y`
6666
6767error[E0425]: cannot find value `a` in this scope
6868  --> $DIR/issue-14254.rs:51:9
Original file line number Diff line number Diff line change @@ -20,10 +20,7 @@ error[E0425]: cannot find value `whiskers` in this scope
2020  --> $DIR/issue-2356.rs:39:5
2121   |
2222LL |     whiskers -= other;
23-    |     ^^^^^^^^
24-    |     |
25-    |     `self` value is a keyword only available in methods with `self` parameter
26-    |     help: try: `self.whiskers`
23+    |     ^^^^^^^^ a field by this name exists in `Self`
2724
2825error[E0425]: cannot find function `shave` in this scope
2926  --> $DIR/issue-2356.rs:41:5
@@ -83,16 +80,13 @@ error[E0425]: cannot find value `whiskers` in this scope
8380  --> $DIR/issue-2356.rs:79:5
8481   |
8582LL |     whiskers = 0;
86-    |     ^^^^^^^^ help: try : `self.whiskers`
83+    |     ^^^^^^^^ help: you might have meant to use the available field : `self.whiskers`
8784
8885error[E0425]: cannot find value `whiskers` in this scope
8986  --> $DIR/issue-2356.rs:84:5
9087   |
9188LL |     whiskers = 4;
92-    |     ^^^^^^^^
93-    |     |
94-    |     `self` value is a keyword only available in methods with `self` parameter
95-    |     help: try: `self.whiskers`
89+    |     ^^^^^^^^ a field by this name exists in `Self`
9690
9791error[E0425]: cannot find function `purr_louder` in this scope
9892  --> $DIR/issue-2356.rs:86:5
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ error[E0425]: cannot find value `field` in this scope
1414  --> $DIR/resolve-assoc-suggestions.rs:20:9
1515   |
1616LL |         field;
17-    |         ^^^^^ help: try : `self.field`
17+    |         ^^^^^ help: you might have meant to use the available field : `self.field`
1818
1919error[E0412]: cannot find type `Type` in this scope
2020  --> $DIR/resolve-assoc-suggestions.rs:23:16
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ error[E0425]: cannot find value `field` in this scope
1414  --> $DIR/resolve-speculative-adjustment.rs:23:9
1515   |
1616LL |         field;
17-    |         ^^^^^ help: try : `self.field`
17+    |         ^^^^^ help: you might have meant to use the available field : `self.field`
1818
1919error[E0425]: cannot find function `method` in this scope
2020  --> $DIR/resolve-speculative-adjustment.rs:25:9
Original file line number Diff line number Diff line change @@ -2,10 +2,7 @@ error[E0425]: cannot find value `cx` in this scope
22  --> $DIR/unresolved_static_type_field.rs:9:11
33   |
44LL |         f(cx);
5-    |           ^^
6-    |           |
7-    |           `self` value is a keyword only available in methods with `self` parameter
8-    |           help: try: `self.cx`
5+    |           ^^ a field by this name exists in `Self`
96
107error: aborting due to previous error
118
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments