Forbid opaque types in extern blocks
This commit is contained in:
parent
740dd4bf05
commit
df7e496f85
3 changed files with 63 additions and 0 deletions
16
src/test/ui/lint/opaque-ty-ffi-unsafe.rs
Normal file
16
src/test/ui/lint/opaque-ty-ffi-unsafe.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#![deny(improper_ctypes)]
|
||||
|
||||
type A = impl Fn();
|
||||
|
||||
pub fn ret_closure() -> A {
|
||||
|| {}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn a(_: A);
|
||||
//~^ ERROR `extern` block uses type `A` which is not FFI-safe: opaque types have no C equivalent
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
14
src/test/ui/lint/opaque-ty-ffi-unsafe.stderr
Normal file
14
src/test/ui/lint/opaque-ty-ffi-unsafe.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error: `extern` block uses type `A` which is not FFI-safe: opaque types have no C equivalent
|
||||
--> $DIR/opaque-ty-ffi-unsafe.rs:12:17
|
||||
|
|
||||
LL | pub fn a(_: A);
|
||||
| ^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/opaque-ty-ffi-unsafe.rs:3:9
|
||||
|
|
||||
LL | #![deny(improper_ctypes)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue