ptr lint: check_mut_from_ref is checked independently of the function's ABI

This commit is contained in:
Milo Moisson 2023-07-24 01:23:35 +02:00
parent 30d06a810c
commit 7b8598d6c0
No known key found for this signature in database
GPG key ID: 7EA9B7563C01CA5E

View file

@ -163,12 +163,13 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
return; return;
} }
check_mut_from_ref(cx, sig, None);
if !matches!(sig.header.abi, Abi::Rust) { if !matches!(sig.header.abi, Abi::Rust) {
// Ignore `extern` functions with non-Rust calling conventions // Ignore `extern` functions with non-Rust calling conventions
return; return;
} }
check_mut_from_ref(cx, sig, None);
for arg in check_fn_args( for arg in check_fn_args(
cx, cx,
cx.tcx.fn_sig(item.owner_id).subst_identity().skip_binder().inputs(), cx.tcx.fn_sig(item.owner_id).subst_identity().skip_binder().inputs(),
@ -223,12 +224,13 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
_ => return, _ => return,
}; };
check_mut_from_ref(cx, sig, Some(body));
if !matches!(sig.header.abi, Abi::Rust) { if !matches!(sig.header.abi, Abi::Rust) {
// Ignore `extern` functions with non-Rust calling conventions // Ignore `extern` functions with non-Rust calling conventions
return; return;
} }
check_mut_from_ref(cx, sig, Some(body));
let decl = sig.decl; let decl = sig.decl;
let sig = cx.tcx.fn_sig(item_id).subst_identity().skip_binder(); let sig = cx.tcx.fn_sig(item_id).subst_identity().skip_binder();
let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, &decl.output, body.params) let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, &decl.output, body.params)