@@ -70,7 +70,7 @@ use syntax::feature_gate::{feature_err, GateIssue};
7070use syntax:: ptr:: P ;
7171
7272use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
73- use errors:: { DiagnosticBuilder , DiagnosticId } ;
73+ use errors:: { Applicability , DiagnosticBuilder , DiagnosticId } ;
7474
7575use std:: cell:: { Cell , RefCell } ;
7676use std:: cmp;
@@ -221,9 +221,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
221221 let sugg_msg = "try using a local type parameter instead" ;
222222 if let Some ( ( sugg_span, new_snippet) ) = cm. generate_local_type_param_snippet ( span) {
223223 // 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+ ) ;
227230 } else if let Some ( sp) = cm. generate_fn_name_span ( span) {
228231 err. span_label ( sp, "try adding a local type parameter in this method instead" ) ;
229232 } else {
@@ -3004,8 +3007,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30043007 enum_path) ;
30053008 err. help ( & msg) ;
30063009 } 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+ ) ;
30093016 }
30103017 }
30113018 }
@@ -3014,20 +3021,32 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30143021 let self_is_available = this. self_value_is_available ( path[ 0 ] . span , span) ;
30153022 match candidate {
30163023 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+ ) ;
30193030 if !self_is_available {
30203031 err. span_label ( span, format ! ( "`self` value is only available in \
30213032 methods with `self` parameter") ) ;
30223033 }
30233034 }
30243035 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+ ) ;
30273042 }
30283043 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+ ) ;
30313050 }
30323051 }
30333052 return ( err, candidates) ;
@@ -4662,15 +4681,16 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
46624681 format ! ( "other_{}" , name)
46634682 } ;
46644683
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+ ) ;
46744694 } else {
46754695 err. span_label ( binding. span , rename_msg) ;
46764696 }
0 commit comments