@@ -1691,20 +1691,18 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
16911691
16921692 lint_cast_ptr_alignment ( cx, expr, cast_from, cast_to) ;
16931693 } else if let ExprKind :: MethodCall ( method_path, _, args, _) = expr. kind {
1694- if method_path. ident . name != sym ! ( cast) {
1695- return ;
1696- }
16971694 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+ }
17051705 }
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) ;
17081706 }
17091707 }
17101708}
0 commit comments