mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-16 17:58:14 +00:00
Simplify cast_ptr_alignment
pointer::casr
case
This commit is contained in:
parent
ee9b47dae6
commit
53f87310cd
1 changed files with 10 additions and 12 deletions
|
@ -1691,20 +1691,18 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
|
|||
|
||||
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
|
||||
} else if let ExprKind::MethodCall(method_path, _, args, _) = expr.kind {
|
||||
if method_path.ident.name != sym!(cast) {
|
||||
return;
|
||||
}
|
||||
if_chain! {
|
||||
if let Some(generic_args) = method_path.args;
|
||||
if let [GenericArg::Type(cast_to)] = generic_args.args;
|
||||
// There probably is no obvious reason to do this, just to be consistent with `as` cases.
|
||||
if is_hir_ty_cfg_dependant(cx, cast_to);
|
||||
then {
|
||||
return;
|
||||
}
|
||||
if method_path.ident.name == sym!(cast);
|
||||
if let Some(generic_args) = method_path.args;
|
||||
if let [GenericArg::Type(cast_to)] = generic_args.args;
|
||||
// There probably is no obvious reason to do this, just to be consistent with `as` cases.
|
||||
if !is_hir_ty_cfg_dependant(cx, cast_to);
|
||||
then {
|
||||
let (cast_from, cast_to) =
|
||||
(cx.typeck_results().expr_ty(&args[0]), cx.typeck_results().expr_ty(expr));
|
||||
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
|
||||
}
|
||||
}
|
||||
let (cast_from, cast_to) = (cx.typeck_results().expr_ty(&args[0]), cx.typeck_results().expr_ty(expr));
|
||||
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue