@@ -2,7 +2,8 @@ use std::borrow::Cow;
22use std:: ops:: Range ;
33
44use 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 } ;
67use rustc_ast:: token;
78use rustc_ast:: tokenstream:: TokenStream ;
89use rustc_errors:: Applicability ;
@@ -442,7 +443,12 @@ impl Write {
442443 return ( Some ( fmtstr) , None ) ;
443444 } ;
444445 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+ {
446452 let mut all_simple = true ;
447453 let mut seen = false ;
448454 for arg in & args {
@@ -460,10 +466,16 @@ impl Write {
460466 span_lint ( cx, lint, token_expr. span , "literal with an empty format string" ) ;
461467 }
462468 idx += 1 ;
463- } ,
469+ }
464470 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 {
467479 let mut all_simple = true ;
468480 let mut seen = false ;
469481 for arg in & args {
0 commit comments