Add regression test for #134060

Mostly just to check that the lint impl doesn't ICE from an easy case.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-12-09 17:39:08 +08:00
parent 1fcbb1e338
commit 38bfd88db7
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,15 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/134060> due to impl bug from
//! <https://github.com/rust-lang/rust/pull/131669>. This test should be adjusted in favor of more
//! comprehensive coverage when the changes are to be relanded, as this is a basic sanity check to
//! check that the fuzzed example from #134060 doesn't ICE.
//@ check-pass
#![crate_type = "lib"]
pub trait Foo {
extern "C" fn foo_(&self, _: ()) -> i64 {
//~^ WARN `extern` fn uses type `()`, which is not FFI-safe
0
}
}

View file

@ -0,0 +1,12 @@
warning: `extern` fn uses type `()`, which is not FFI-safe
--> $DIR/improper_ctypes_definitions_ice_134060.rs:11:34
|
LL | extern "C" fn foo_(&self, _: ()) -> i64 {
| ^^ not FFI-safe
|
= help: consider using a struct instead
= note: tuples have unspecified layout
= note: `#[warn(improper_ctypes_definitions)]` on by default
warning: 1 warning emitted