@@ -69,7 +69,7 @@ use syntax::feature_gate::{feature_err, GateIssue};
69
69
use syntax:: ptr:: P ;
70
70
71
71
use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
72
- use errors:: { DiagnosticBuilder , DiagnosticId } ;
72
+ use errors:: { Applicability , DiagnosticBuilder , DiagnosticId } ;
73
73
74
74
use std:: cell:: { Cell , RefCell } ;
75
75
use std:: cmp;
@@ -220,9 +220,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
220
220
let sugg_msg = "try using a local type parameter instead" ;
221
221
if let Some ( ( sugg_span, new_snippet) ) = cm. generate_local_type_param_snippet ( span) {
222
222
// Suggest the modification to the user
223
- err. span_suggestion ( sugg_span,
224
- sugg_msg,
225
- new_snippet) ;
223
+ err. span_suggestion_with_applicability (
224
+ sugg_span,
225
+ sugg_msg,
226
+ new_snippet,
227
+ Applicability :: MachineApplicable ,
228
+ ) ;
226
229
} else if let Some ( sp) = cm. generate_fn_name_span ( span) {
227
230
err. span_label ( sp, "try adding a local type parameter in this method instead" ) ;
228
231
} else {
@@ -2998,8 +3001,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2998
3001
enum_path) ;
2999
3002
err. help ( & msg) ;
3000
3003
} else {
3001
- err. span_suggestion ( span, "you can try using the variant's enum" ,
3002
- enum_path) ;
3004
+ err. span_suggestion_with_applicability (
3005
+ span,
3006
+ "you can try using the variant's enum" ,
3007
+ enum_path,
3008
+ Applicability :: MachineApplicable ,
3009
+ ) ;
3003
3010
}
3004
3011
}
3005
3012
}
@@ -3008,20 +3015,32 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3008
3015
let self_is_available = this. self_value_is_available ( path[ 0 ] . span , span) ;
3009
3016
match candidate {
3010
3017
AssocSuggestion :: Field => {
3011
- err. span_suggestion ( span, "try" ,
3012
- format ! ( "self.{}" , path_str) ) ;
3018
+ err. span_suggestion_with_applicability (
3019
+ span,
3020
+ "try" ,
3021
+ format ! ( "self.{}" , path_str) ,
3022
+ Applicability :: MachineApplicable ,
3023
+ ) ;
3013
3024
if !self_is_available {
3014
3025
err. span_label ( span, format ! ( "`self` value is only available in \
3015
3026
methods with `self` parameter") ) ;
3016
3027
}
3017
3028
}
3018
3029
AssocSuggestion :: MethodWithSelf if self_is_available => {
3019
- err. span_suggestion ( span, "try" ,
3020
- format ! ( "self.{}" , path_str) ) ;
3030
+ err. span_suggestion_with_applicability (
3031
+ span,
3032
+ "try" ,
3033
+ format ! ( "self.{}" , path_str) ,
3034
+ Applicability :: MachineApplicable ,
3035
+ ) ;
3021
3036
}
3022
3037
AssocSuggestion :: MethodWithSelf | AssocSuggestion :: AssocItem => {
3023
- err. span_suggestion ( span, "try" ,
3024
- format ! ( "Self::{}" , path_str) ) ;
3038
+ err. span_suggestion_with_applicability (
3039
+ span,
3040
+ "try" ,
3041
+ format ! ( "Self::{}" , path_str) ,
3042
+ Applicability :: MachineApplicable ,
3043
+ ) ;
3025
3044
}
3026
3045
}
3027
3046
return ( err, candidates) ;
@@ -4617,15 +4636,16 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4617
4636
format ! ( "other_{}" , name)
4618
4637
} ;
4619
4638
4620
- err. span_suggestion ( binding. span ,
4621
- rename_msg,
4622
- if snippet. ends_with ( ';' ) {
4623
- format ! ( "{} as {};" ,
4624
- & snippet[ ..snippet. len( ) -1 ] ,
4625
- suggested_name)
4626
- } else {
4627
- format ! ( "{} as {}" , snippet, suggested_name)
4628
- } ) ;
4639
+ err. span_suggestion_with_applicability (
4640
+ binding. span ,
4641
+ rename_msg,
4642
+ if snippet. ends_with ( ';' ) {
4643
+ format ! ( "{} as {};" , & snippet[ ..snippet. len( ) - 1 ] , suggested_name)
4644
+ } else {
4645
+ format ! ( "{} as {}" , snippet, suggested_name)
4646
+ } ,
4647
+ Applicability :: MachineApplicable ,
4648
+ ) ;
4629
4649
} else {
4630
4650
err. span_label ( binding. span , rename_msg) ;
4631
4651
}
0 commit comments