@@ -1214,23 +1214,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
12141214 if let LitKind :: Int ( n, _) = lit. node;
12151215 if let Some ( src) = snippet_opt( cx, lit. span) ;
12161216 if cast_to. is_floating_point( ) ;
1217+ if let Some ( num_lit) = NumericLiteral :: from_lit_kind( & src, & lit. node) ;
1218+ let from_nbits = 128 - n. leading_zeros( ) ;
1219+ let to_nbits = fp_ty_mantissa_nbits( cast_to) ;
1220+ if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit. is_decimal( ) ;
12171221 then {
1218- let from_nbits = 128 - n. leading_zeros( ) ;
1219- let to_nbits = fp_ty_mantissa_nbits( cast_to) ;
1220- if let Some ( num_lit) = NumericLiteral :: from_lit_kind( & src, & lit. node) {
1221- if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits && num_lit. is_decimal( ) {
1222- span_lint_and_sugg(
1223- cx,
1224- UNNECESSARY_CAST ,
1225- expr. span,
1226- & format!( "casting integer literal to `{}` is unnecessary" , cast_to) ,
1227- "try" ,
1228- format!( "{}_{}" , n, cast_to) ,
1229- Applicability :: MachineApplicable ,
1230- ) ;
1231- return ;
1232- }
1233- }
1222+ span_lint_and_sugg(
1223+ cx,
1224+ UNNECESSARY_CAST ,
1225+ expr. span,
1226+ & format!( "casting integer literal to `{}` is unnecessary" , cast_to) ,
1227+ "try" ,
1228+ format!( "{}_{}" , n, cast_to) ,
1229+ Applicability :: MachineApplicable ,
1230+ ) ;
1231+ return ;
12341232 }
12351233 }
12361234 match lit. node {
0 commit comments