@@ -1214,23 +1214,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
1214
1214
if let LitKind :: Int ( n, _) = lit. node;
1215
1215
if let Some ( src) = snippet_opt( cx, lit. span) ;
1216
1216
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( ) ;
1217
1221
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 ;
1234
1232
}
1235
1233
}
1236
1234
match lit. node {
0 commit comments