@@ -302,8 +302,14 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
302
302
return ;
303
303
}
304
304
lint_fn_to_numeric_cast ( cx, expr, cast_expr, cast_from, cast_to) ;
305
- lint_numeric_casts ( cx, expr, cast_expr, cast_from, cast_to) ;
306
305
lint_cast_ptr_alignment ( cx, expr, cast_from, cast_to) ;
306
+ if cast_from. is_numeric ( ) && cast_to. is_numeric ( ) && !in_external_macro ( cx. sess ( ) , expr. span ) {
307
+ cast_possible_truncation:: check ( cx, expr, cast_from, cast_to) ;
308
+ cast_possible_wrap:: check ( cx, expr, cast_from, cast_to) ;
309
+ cast_precision_loss:: check ( cx, expr, cast_from, cast_to) ;
310
+ cast_lossless:: check ( cx, expr, cast_expr, cast_from, cast_to) ;
311
+ cast_sign_loss:: check ( cx, expr, cast_expr, cast_from, cast_to) ;
312
+ }
307
313
} else if let ExprKind :: MethodCall ( method_path, _, args, _) = expr. kind {
308
314
if_chain ! {
309
315
if method_path. ident. name == sym!( cast) ;
@@ -321,22 +327,6 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
321
327
}
322
328
}
323
329
324
- fn lint_numeric_casts < ' tcx > (
325
- cx : & LateContext < ' tcx > ,
326
- expr : & Expr < ' tcx > ,
327
- cast_op : & Expr < ' _ > ,
328
- cast_from : Ty < ' tcx > ,
329
- cast_to : Ty < ' tcx > ,
330
- ) {
331
- if cast_from. is_numeric ( ) && cast_to. is_numeric ( ) && !in_external_macro ( cx. sess ( ) , expr. span ) {
332
- cast_possible_truncation:: check ( cx, expr, cast_from, cast_to) ;
333
- cast_possible_wrap:: check ( cx, expr, cast_from, cast_to) ;
334
- cast_precision_loss:: check ( cx, expr, cast_from, cast_to) ;
335
- cast_lossless:: check ( cx, expr, cast_op, cast_from, cast_to) ;
336
- cast_sign_loss:: check ( cx, expr, cast_op, cast_from, cast_to) ;
337
- }
338
- }
339
-
340
330
fn lint_cast_ptr_alignment < ' tcx > ( cx : & LateContext < ' tcx > , expr : & Expr < ' _ > , cast_from : Ty < ' tcx > , cast_to : Ty < ' tcx > ) {
341
331
if_chain ! {
342
332
if let ty:: RawPtr ( from_ptr_ty) = & cast_from. kind( ) ;
0 commit comments