@@ -5,8 +5,9 @@ mod redundant_pattern;
55mod unneeded_field_pattern;
66mod unneeded_wildcard_pattern;
77mod unseparated_literal_suffix;
8+ mod zero_prefixed_literal;
89
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} ;
1011use clippy_utils:: source:: snippet_opt;
1112use rustc_ast:: ast:: { Expr , Generics , Lit , LitFloatType , LitIntType , LitKind , NodeId , Pat , PatKind } ;
1213use rustc_ast:: visit:: FnKind ;
@@ -356,26 +357,7 @@ impl MiscEarlyLints {
356357 } else if lit_snip. starts_with ( "0b" ) || lit_snip. starts_with ( "0o" ) {
357358 /* nothing to do */
358359 } 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)
379361 }
380362 } else if let LitKind :: Float ( _, LitFloatType :: Suffixed ( float_ty) ) = lit. kind {
381363 unseparated_literal_suffix:: check ( cx, lit, float_ty, lit_snip)
0 commit comments