mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
ptr_arg should ignore extern functions
This commit is contained in:
parent
43577d58f9
commit
30d06a810c
2 changed files with 24 additions and 0 deletions
|
@ -26,6 +26,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
|||
use rustc_span::source_map::Span;
|
||||
use rustc_span::sym;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||
use std::{fmt, iter};
|
||||
|
@ -162,6 +163,11 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
|||
return;
|
||||
}
|
||||
|
||||
if !matches!(sig.header.abi, Abi::Rust) {
|
||||
// Ignore `extern` functions with non-Rust calling conventions
|
||||
return;
|
||||
}
|
||||
|
||||
check_mut_from_ref(cx, sig, None);
|
||||
for arg in check_fn_args(
|
||||
cx,
|
||||
|
@ -217,6 +223,11 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
|||
_ => return,
|
||||
};
|
||||
|
||||
if !matches!(sig.header.abi, Abi::Rust) {
|
||||
// Ignore `extern` functions with non-Rust calling conventions
|
||||
return;
|
||||
}
|
||||
|
||||
check_mut_from_ref(cx, sig, Some(body));
|
||||
let decl = sig.decl;
|
||||
let sig = cx.tcx.fn_sig(item_id).subst_identity().skip_binder();
|
||||
|
|
|
@ -267,3 +267,16 @@ mod issue_9218 {
|
|||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
mod issue_11181 {
|
||||
extern "C" fn allowed(_v: &Vec<u32>) {}
|
||||
|
||||
struct S;
|
||||
impl S {
|
||||
extern "C" fn allowed(_v: &Vec<u32>) {}
|
||||
}
|
||||
|
||||
trait T {
|
||||
extern "C" fn allowed(_v: &Vec<u32>) {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue