1414//! compiler code, rather than using their own custom pass. Those
1515//! lints are all available in `rustc_lint::builtin`.
1616
17- use errors:: DiagnosticBuilder ;
17+ use errors:: { Applicability , DiagnosticBuilder } ;
1818use lint:: { LintPass , LateLintPass , LintArray } ;
1919use session:: Session ;
2020use syntax:: codemap:: Span ;
@@ -341,15 +341,16 @@ impl BuiltinLintDiagnostics {
341341 match self {
342342 BuiltinLintDiagnostics :: Normal => ( ) ,
343343 BuiltinLintDiagnostics :: BareTraitObject ( span, is_global) => {
344- let sugg = match sess. codemap ( ) . span_to_snippet ( span) {
345- Ok ( ref s) if is_global => format ! ( "dyn ({})" , s) ,
346- Ok ( s) => format ! ( "dyn {}" , s) ,
347- Err ( _) => format ! ( "dyn <type>" )
344+ let ( sugg, app) = match sess. codemap ( ) . span_to_snippet ( span) {
345+ Ok ( ref s) if is_global => ( format ! ( "dyn ({})" , s) ,
346+ Applicability :: MachineApplicable ) ,
347+ Ok ( s) => ( format ! ( "dyn {}" , s) , Applicability :: MachineApplicable ) ,
348+ Err ( _) => ( format ! ( "dyn <type>" ) , Applicability :: HasPlaceholders )
348349 } ;
349- db. span_suggestion ( span, "use `dyn`" , sugg) ;
350+ db. span_suggestion_with_applicability ( span, "use `dyn`" , sugg, app ) ;
350351 }
351352 BuiltinLintDiagnostics :: AbsPathWithModule ( span) => {
352- let sugg = match sess. codemap ( ) . span_to_snippet ( span) {
353+ let ( sugg, app ) = match sess. codemap ( ) . span_to_snippet ( span) {
353354 Ok ( ref s) => {
354355 // FIXME(Manishearth) ideally the emitting code
355356 // can tell us whether or not this is global
@@ -359,11 +360,11 @@ impl BuiltinLintDiagnostics {
359360 "::"
360361 } ;
361362
362- format ! ( "crate{}{}" , opt_colon, s)
363+ ( format ! ( "crate{}{}" , opt_colon, s) , Applicability :: MachineApplicable )
363364 }
364- Err ( _) => format ! ( "crate::<path>" )
365+ Err ( _) => ( format ! ( "crate::<path>" ) , Applicability :: HasPlaceholders )
365366 } ;
366- db. span_suggestion ( span, "use `crate`" , sugg) ;
367+ db. span_suggestion_with_applicability ( span, "use `crate`" , sugg, app ) ;
367368 }
368369 }
369370 }
0 commit comments