@@ -5,8 +5,9 @@ mod redundant_pattern;
5
5
mod unneeded_field_pattern;
6
6
mod unneeded_wildcard_pattern;
7
7
mod unseparated_literal_suffix;
8
+ mod zero_prefixed_literal;
8
9
9
- use clippy_utils:: diagnostics:: { span_lint, span_lint_and_sugg, span_lint_and_then } ;
10
+ use clippy_utils:: diagnostics:: { span_lint, span_lint_and_sugg} ;
10
11
use clippy_utils:: source:: snippet_opt;
11
12
use rustc_ast:: ast:: { Expr , Generics , Lit , LitFloatType , LitIntType , LitKind , NodeId , Pat , PatKind } ;
12
13
use rustc_ast:: visit:: FnKind ;
@@ -356,26 +357,7 @@ impl MiscEarlyLints {
356
357
} else if lit_snip. starts_with ( "0b" ) || lit_snip. starts_with ( "0o" ) {
357
358
/* nothing to do */
358
359
} else if value != 0 && lit_snip. starts_with ( '0' ) {
359
- span_lint_and_then (
360
- cx,
361
- ZERO_PREFIXED_LITERAL ,
362
- lit. span ,
363
- "this is a decimal constant" ,
364
- |diag| {
365
- diag. span_suggestion (
366
- lit. span ,
367
- "if you mean to use a decimal constant, remove the `0` to avoid confusion" ,
368
- lit_snip. trim_start_matches ( |c| c == '_' || c == '0' ) . to_string ( ) ,
369
- Applicability :: MaybeIncorrect ,
370
- ) ;
371
- diag. span_suggestion (
372
- lit. span ,
373
- "if you mean to use an octal constant, use `0o`" ,
374
- format ! ( "0o{}" , lit_snip. trim_start_matches( |c| c == '_' || c == '0' ) ) ,
375
- Applicability :: MaybeIncorrect ,
376
- ) ;
377
- } ,
378
- ) ;
360
+ zero_prefixed_literal:: check ( cx, lit, lit_snip)
379
361
}
380
362
} else if let LitKind :: Float ( _, LitFloatType :: Suffixed ( float_ty) ) = lit. kind {
381
363
unseparated_literal_suffix:: check ( cx, lit, float_ty, lit_snip)
0 commit comments