@@ -1691,20 +1691,18 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
1691
1691
1692
1692
lint_cast_ptr_alignment ( cx, expr, cast_from, cast_to) ;
1693
1693
} else if let ExprKind :: MethodCall ( method_path, _, args, _) = expr. kind {
1694
- if method_path. ident . name != sym ! ( cast) {
1695
- return ;
1696
- }
1697
1694
if_chain ! {
1698
- if let Some ( generic_args) = method_path. args;
1699
- if let [ GenericArg :: Type ( cast_to) ] = generic_args. args;
1700
- // There probably is no obvious reason to do this, just to be consistent with `as` cases.
1701
- if is_hir_ty_cfg_dependant( cx, cast_to) ;
1702
- then {
1703
- return ;
1704
- }
1695
+ if method_path. ident. name == sym!( cast) ;
1696
+ if let Some ( generic_args) = method_path. args;
1697
+ if let [ GenericArg :: Type ( cast_to) ] = generic_args. args;
1698
+ // There probably is no obvious reason to do this, just to be consistent with `as` cases.
1699
+ if !is_hir_ty_cfg_dependant( cx, cast_to) ;
1700
+ then {
1701
+ let ( cast_from, cast_to) =
1702
+ ( cx. typeck_results( ) . expr_ty( & args[ 0 ] ) , cx. typeck_results( ) . expr_ty( expr) ) ;
1703
+ lint_cast_ptr_alignment( cx, expr, cast_from, cast_to) ;
1704
+ }
1705
1705
}
1706
- let ( cast_from, cast_to) = ( cx. typeck_results ( ) . expr_ty ( & args[ 0 ] ) , cx. typeck_results ( ) . expr_ty ( expr) ) ;
1707
- lint_cast_ptr_alignment ( cx, expr, cast_from, cast_to) ;
1708
1706
}
1709
1707
}
1710
1708
}
0 commit comments