@@ -70,7 +70,7 @@ use syntax::feature_gate::{feature_err, GateIssue};
70
70
use syntax:: ptr:: P ;
71
71
72
72
use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
73
- use errors:: { DiagnosticBuilder , DiagnosticId } ;
73
+ use errors:: { Applicability , DiagnosticBuilder , DiagnosticId } ;
74
74
75
75
use std:: cell:: { Cell , RefCell } ;
76
76
use std:: cmp;
@@ -221,9 +221,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
221
221
let sugg_msg = "try using a local type parameter instead" ;
222
222
if let Some ( ( sugg_span, new_snippet) ) = cm. generate_local_type_param_snippet ( span) {
223
223
// Suggest the modification to the user
224
- err. span_suggestion ( sugg_span,
225
- sugg_msg,
226
- new_snippet) ;
224
+ err. span_suggestion_with_applicability (
225
+ sugg_span,
226
+ sugg_msg,
227
+ new_snippet,
228
+ Applicability :: MachineApplicable ,
229
+ ) ;
227
230
} else if let Some ( sp) = cm. generate_fn_name_span ( span) {
228
231
err. span_label ( sp, "try adding a local type parameter in this method instead" ) ;
229
232
} else {
@@ -3004,8 +3007,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3004
3007
enum_path) ;
3005
3008
err. help ( & msg) ;
3006
3009
} else {
3007
- err. span_suggestion ( span, "you can try using the variant's enum" ,
3008
- enum_path) ;
3010
+ err. span_suggestion_with_applicability (
3011
+ span,
3012
+ "you can try using the variant's enum" ,
3013
+ enum_path,
3014
+ Applicability :: MachineApplicable ,
3015
+ ) ;
3009
3016
}
3010
3017
}
3011
3018
}
@@ -3014,20 +3021,32 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3014
3021
let self_is_available = this. self_value_is_available ( path[ 0 ] . span , span) ;
3015
3022
match candidate {
3016
3023
AssocSuggestion :: Field => {
3017
- err. span_suggestion ( span, "try" ,
3018
- format ! ( "self.{}" , path_str) ) ;
3024
+ err. span_suggestion_with_applicability (
3025
+ span,
3026
+ "try" ,
3027
+ format ! ( "self.{}" , path_str) ,
3028
+ Applicability :: MachineApplicable ,
3029
+ ) ;
3019
3030
if !self_is_available {
3020
3031
err. span_label ( span, format ! ( "`self` value is only available in \
3021
3032
methods with `self` parameter") ) ;
3022
3033
}
3023
3034
}
3024
3035
AssocSuggestion :: MethodWithSelf if self_is_available => {
3025
- err. span_suggestion ( span, "try" ,
3026
- format ! ( "self.{}" , path_str) ) ;
3036
+ err. span_suggestion_with_applicability (
3037
+ span,
3038
+ "try" ,
3039
+ format ! ( "self.{}" , path_str) ,
3040
+ Applicability :: MachineApplicable ,
3041
+ ) ;
3027
3042
}
3028
3043
AssocSuggestion :: MethodWithSelf | AssocSuggestion :: AssocItem => {
3029
- err. span_suggestion ( span, "try" ,
3030
- format ! ( "Self::{}" , path_str) ) ;
3044
+ err. span_suggestion_with_applicability (
3045
+ span,
3046
+ "try" ,
3047
+ format ! ( "Self::{}" , path_str) ,
3048
+ Applicability :: MachineApplicable ,
3049
+ ) ;
3031
3050
}
3032
3051
}
3033
3052
return ( err, candidates) ;
@@ -4662,15 +4681,16 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4662
4681
format ! ( "other_{}" , name)
4663
4682
} ;
4664
4683
4665
- err. span_suggestion ( binding. span ,
4666
- rename_msg,
4667
- if snippet. ends_with ( ';' ) {
4668
- format ! ( "{} as {};" ,
4669
- & snippet[ ..snippet. len( ) -1 ] ,
4670
- suggested_name)
4671
- } else {
4672
- format ! ( "{} as {}" , snippet, suggested_name)
4673
- } ) ;
4684
+ err. span_suggestion_with_applicability (
4685
+ binding. span ,
4686
+ rename_msg,
4687
+ if snippet. ends_with ( ';' ) {
4688
+ format ! ( "{} as {};" , & snippet[ ..snippet. len( ) - 1 ] , suggested_name)
4689
+ } else {
4690
+ format ! ( "{} as {}" , snippet, suggested_name)
4691
+ } ,
4692
+ Applicability :: MachineApplicable ,
4693
+ ) ;
4674
4694
} else {
4675
4695
err. span_label ( binding. span , rename_msg) ;
4676
4696
}
0 commit comments