@@ -2,7 +2,8 @@ use std::borrow::Cow;
2
2
use std:: ops:: Range ;
3
3
4
4
use crate :: utils:: { snippet_with_applicability, span_lint, span_lint_and_sugg, span_lint_and_then} ;
5
- use rustc_ast:: ast:: { Expr , ExprKind , Item , ItemKind , MacCall , StrLit , StrStyle } ;
5
+ use if_chain:: if_chain;
6
+ use rustc_ast:: ast:: { Expr , ExprKind , Item , ItemKind , LitKind , MacCall , StrLit , StrStyle } ;
6
7
use rustc_ast:: token;
7
8
use rustc_ast:: tokenstream:: TokenStream ;
8
9
use rustc_errors:: Applicability ;
@@ -442,7 +443,12 @@ impl Write {
442
443
return ( Some ( fmtstr) , None ) ;
443
444
} ;
444
445
match & token_expr. kind {
445
- ExprKind :: Lit ( _) => {
446
+ ExprKind :: Lit ( lit)
447
+ if match lit. kind {
448
+ LitKind :: Int ( _, _) | LitKind :: Float ( _, _) => false ,
449
+ _ => true ,
450
+ } =>
451
+ {
446
452
let mut all_simple = true ;
447
453
let mut seen = false ;
448
454
for arg in & args {
@@ -460,10 +466,16 @@ impl Write {
460
466
span_lint ( cx, lint, token_expr. span , "literal with an empty format string" ) ;
461
467
}
462
468
idx += 1 ;
463
- } ,
469
+ }
464
470
ExprKind :: Assign ( lhs, rhs, _) => {
465
- if let ExprKind :: Lit ( _) = rhs. kind {
466
- if let ExprKind :: Path ( _, p) = & lhs. kind {
471
+ if_chain ! {
472
+ if let ExprKind :: Lit ( ref lit) = rhs. kind;
473
+ if match lit. kind {
474
+ LitKind :: Int ( _, _) | LitKind :: Float ( _, _) => false ,
475
+ _ => true ,
476
+ } ;
477
+ if let ExprKind :: Path ( _, p) = & lhs. kind;
478
+ then {
467
479
let mut all_simple = true ;
468
480
let mut seen = false ;
469
481
for arg in & args {
0 commit comments