File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
2626use rustc_span:: source_map:: Span ;
2727use rustc_span:: sym;
2828use rustc_span:: symbol:: Symbol ;
29+ use rustc_target:: spec:: abi:: Abi ;
2930use rustc_trait_selection:: infer:: InferCtxtExt as _;
3031use rustc_trait_selection:: traits:: query:: evaluate_obligation:: InferCtxtExt as _;
3132use std:: { fmt, iter} ;
@@ -162,6 +163,11 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
162163 return ;
163164 }
164165
166+ if !matches ! ( sig. header. abi, Abi :: Rust ) {
167+ // Ignore `extern` functions with non-Rust calling conventions
168+ return ;
169+ }
170+
165171 check_mut_from_ref ( cx, sig, None ) ;
166172 for arg in check_fn_args (
167173 cx,
@@ -217,6 +223,11 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
217223 _ => return ,
218224 } ;
219225
226+ if !matches ! ( sig. header. abi, Abi :: Rust ) {
227+ // Ignore `extern` functions with non-Rust calling conventions
228+ return ;
229+ }
230+
220231 check_mut_from_ref ( cx, sig, Some ( body) ) ;
221232 let decl = sig. decl ;
222233 let sig = cx. tcx . fn_sig ( item_id) . subst_identity ( ) . skip_binder ( ) ;
Original file line number Diff line number Diff line change @@ -267,3 +267,16 @@ mod issue_9218 {
267267 todo ! ( )
268268 }
269269}
270+
271+ mod issue_11181 {
272+ extern "C" fn allowed ( _v : & Vec < u32 > ) { }
273+
274+ struct S ;
275+ impl S {
276+ extern "C" fn allowed ( _v : & Vec < u32 > ) { }
277+ }
278+
279+ trait T {
280+ extern "C" fn allowed ( _v : & Vec < u32 > ) { }
281+ }
282+ }
You can’t perform that action at this time.
0 commit comments