@@ -69,7 +69,7 @@ use syntax::feature_gate::{feature_err, GateIssue};
6969use syntax:: ptr:: P ;
7070
7171use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
72- use errors:: { DiagnosticBuilder , DiagnosticId } ;
72+ use errors:: { Applicability , DiagnosticBuilder , DiagnosticId } ;
7373
7474use std:: cell:: { Cell , RefCell } ;
7575use std:: cmp;
@@ -220,9 +220,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
220220 let sugg_msg = "try using a local type parameter instead" ;
221221 if let Some ( ( sugg_span, new_snippet) ) = cm. generate_local_type_param_snippet ( span) {
222222 // 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+ ) ;
226229 } else if let Some ( sp) = cm. generate_fn_name_span ( span) {
227230 err. span_label ( sp, "try adding a local type parameter in this method instead" ) ;
228231 } else {
@@ -2998,8 +3001,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
29983001 enum_path) ;
29993002 err. help ( & msg) ;
30003003 } 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+ ) ;
30033010 }
30043011 }
30053012 }
@@ -3008,20 +3015,32 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30083015 let self_is_available = this. self_value_is_available ( path[ 0 ] . span , span) ;
30093016 match candidate {
30103017 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+ ) ;
30133024 if !self_is_available {
30143025 err. span_label ( span, format ! ( "`self` value is only available in \
30153026 methods with `self` parameter") ) ;
30163027 }
30173028 }
30183029 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+ ) ;
30213036 }
30223037 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+ ) ;
30253044 }
30263045 }
30273046 return ( err, candidates) ;
@@ -4617,15 +4636,16 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
46174636 format ! ( "other_{}" , name)
46184637 } ;
46194638
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+ ) ;
46294649 } else {
46304650 err. span_label ( binding. span , rename_msg) ;
46314651 }
0 commit comments