File tree 2 files changed +25
-4
lines changed
2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -332,7 +332,8 @@ impl LintPass for HardwiredLints {
332
332
#[ derive( PartialEq , RustcEncodable , RustcDecodable , Debug ) ]
333
333
pub enum BuiltinLintDiagnostics {
334
334
Normal ,
335
- BareTraitObject ( Span , /* is_global */ bool )
335
+ BareTraitObject ( Span , /* is_global */ bool ) ,
336
+ AbsPathWithModule ( Span ) ,
336
337
}
337
338
338
339
impl BuiltinLintDiagnostics {
@@ -347,6 +348,23 @@ impl BuiltinLintDiagnostics {
347
348
} ;
348
349
db. span_suggestion ( span, "use `dyn`" , sugg) ;
349
350
}
351
+ BuiltinLintDiagnostics :: AbsPathWithModule ( span) => {
352
+ let sugg = match sess. codemap ( ) . span_to_snippet ( span) {
353
+ Ok ( ref s) => {
354
+ // FIXME(Manishearth) ideally the emitting code
355
+ // can tell us whether or not this is global
356
+ let opt_colon = if s. trim_left ( ) . starts_with ( "::" ) {
357
+ ""
358
+ } else {
359
+ "::"
360
+ } ;
361
+
362
+ format ! ( "crate{}{}" , opt_colon, s)
363
+ }
364
+ Err ( _) => format ! ( "crate::<path>" )
365
+ } ;
366
+ db. span_suggestion ( span, "use `crate`" , sugg) ;
367
+ }
350
368
}
351
369
}
352
370
}
Original file line number Diff line number Diff line change @@ -3344,11 +3344,14 @@ impl<'a> Resolver<'a> {
3344
3344
}
3345
3345
3346
3346
if !is_crate {
3347
- self . session . buffer_lint (
3347
+ let diag = lint:: builtin:: BuiltinLintDiagnostics
3348
+ :: AbsPathWithModule ( path_span) ;
3349
+ self . session . buffer_lint_with_diagnostic (
3348
3350
lint:: builtin:: ABSOLUTE_PATH_STARTING_WITH_MODULE ,
3349
3351
id, path_span,
3350
- "Fully-qualified paths must start with `self`, `super`,
3351
- `crate`, or an external crate name in the 2018 edition" ) ;
3352
+ "Absolute paths must start with `self`, `super`, \
3353
+ `crate`, or an external crate name in the 2018 edition",
3354
+ diag) ;
3352
3355
}
3353
3356
}
3354
3357
}
You can’t perform that action at this time.
0 commit comments