14
14
//! compiler code, rather than using their own custom pass. Those
15
15
//! lints are all available in `rustc_lint::builtin`.
16
16
17
- use errors:: DiagnosticBuilder ;
17
+ use errors:: { Applicability , DiagnosticBuilder } ;
18
18
use lint:: { LintPass , LateLintPass , LintArray } ;
19
19
use session:: Session ;
20
20
use syntax:: codemap:: Span ;
@@ -341,15 +341,16 @@ impl BuiltinLintDiagnostics {
341
341
match self {
342
342
BuiltinLintDiagnostics :: Normal => ( ) ,
343
343
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 )
348
349
} ;
349
- db. span_suggestion ( span, "use `dyn`" , sugg) ;
350
+ db. span_suggestion_with_applicability ( span, "use `dyn`" , sugg, app ) ;
350
351
}
351
352
BuiltinLintDiagnostics :: AbsPathWithModule ( span) => {
352
- let sugg = match sess. codemap ( ) . span_to_snippet ( span) {
353
+ let ( sugg, app ) = match sess. codemap ( ) . span_to_snippet ( span) {
353
354
Ok ( ref s) => {
354
355
// FIXME(Manishearth) ideally the emitting code
355
356
// can tell us whether or not this is global
@@ -359,11 +360,11 @@ impl BuiltinLintDiagnostics {
359
360
"::"
360
361
} ;
361
362
362
- format ! ( "crate{}{}" , opt_colon, s)
363
+ ( format ! ( "crate{}{}" , opt_colon, s) , Applicability :: MachineApplicable )
363
364
}
364
- Err ( _) => format ! ( "crate::<path>" )
365
+ Err ( _) => ( format ! ( "crate::<path>" ) , Applicability :: HasPlaceholders )
365
366
} ;
366
- db. span_suggestion ( span, "use `crate`" , sugg) ;
367
+ db. span_suggestion_with_applicability ( span, "use `crate`" , sugg, app ) ;
367
368
}
368
369
}
369
370
}
0 commit comments