mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
Auto merge of #79804 - tmiasko:improper-ctypes-no-niche, r=pnkfelix
Types with a hidden niche are not known to be non-null Fixes #79787.
This commit is contained in:
commit
07194ffcd2
@ -672,7 +672,7 @@ pub fn transparent_newtype_field<'a, 'tcx>(
|
||||
}
|
||||
|
||||
/// Is type known to be non-null?
|
||||
crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool {
|
||||
fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool {
|
||||
let tcx = cx.tcx;
|
||||
match ty.kind() {
|
||||
ty::FnPtr(_) => true,
|
||||
@ -685,6 +685,12 @@ crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: C
|
||||
return true;
|
||||
}
|
||||
|
||||
// Types with a `#[repr(no_niche)]` attribute have their niche hidden.
|
||||
// The attribute is used by the UnsafeCell for example (the only use so far).
|
||||
if def.repr.hide_niche() {
|
||||
return false;
|
||||
}
|
||||
|
||||
for variant in &def.variants {
|
||||
if let Some(field) = transparent_newtype_field(cx.tcx, variant) {
|
||||
if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// check-pass
|
||||
// aux-build:external_extern_fn.rs
|
||||
#![crate_type = "lib"]
|
||||
#![feature(no_niche)]
|
||||
#![warn(clashing_extern_declarations)]
|
||||
|
||||
mod redeclared_different_signature {
|
||||
@ -383,3 +384,36 @@ mod unknown_layout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod hidden_niche {
|
||||
mod a {
|
||||
extern "C" {
|
||||
fn hidden_niche_transparent() -> usize;
|
||||
fn hidden_niche_transparent_no_niche() -> usize;
|
||||
fn hidden_niche_unsafe_cell() -> usize;
|
||||
}
|
||||
}
|
||||
mod b {
|
||||
use std::cell::UnsafeCell;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
#[repr(transparent)]
|
||||
struct Transparent { x: NonZeroUsize }
|
||||
|
||||
#[repr(no_niche)]
|
||||
#[repr(transparent)]
|
||||
struct TransparentNoNiche { y: NonZeroUsize }
|
||||
|
||||
extern "C" {
|
||||
fn hidden_niche_transparent() -> Option<Transparent>;
|
||||
|
||||
fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>;
|
||||
//~^ WARN redeclared with a different signature
|
||||
//~| WARN block uses type `Option<TransparentNoNiche>`, which is not FFI-safe
|
||||
|
||||
fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
|
||||
//~^ WARN redeclared with a different signature
|
||||
//~| WARN block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: `clash` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:14:13
|
||||
--> $DIR/clashing-extern-fn.rs:15:13
|
||||
|
|
||||
LL | fn clash(x: u8);
|
||||
| ---------------- `clash` previously declared here
|
||||
@ -8,7 +8,7 @@ LL | fn clash(x: u64);
|
||||
| ^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/clashing-extern-fn.rs:4:9
|
||||
--> $DIR/clashing-extern-fn.rs:5:9
|
||||
|
|
||||
LL | #![warn(clashing_extern_declarations)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -16,7 +16,7 @@ LL | #![warn(clashing_extern_declarations)]
|
||||
found `unsafe extern "C" fn(u64)`
|
||||
|
||||
warning: `extern_link_name` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:52:9
|
||||
--> $DIR/clashing-extern-fn.rs:53:9
|
||||
|
|
||||
LL | / #[link_name = "extern_link_name"]
|
||||
LL | | fn some_new_name(x: i16);
|
||||
@ -29,7 +29,7 @@ LL | fn extern_link_name(x: u32);
|
||||
found `unsafe extern "C" fn(u32)`
|
||||
|
||||
warning: `some_other_extern_link_name` redeclares `some_other_new_name` with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:55:9
|
||||
--> $DIR/clashing-extern-fn.rs:56:9
|
||||
|
|
||||
LL | fn some_other_new_name(x: i16);
|
||||
| ------------------------------- `some_other_new_name` previously declared here
|
||||
@ -43,7 +43,7 @@ LL | | fn some_other_extern_link_name(x: u32);
|
||||
found `unsafe extern "C" fn(u32)`
|
||||
|
||||
warning: `other_both_names_different` redeclares `link_name_same` with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:59:9
|
||||
--> $DIR/clashing-extern-fn.rs:60:9
|
||||
|
|
||||
LL | / #[link_name = "link_name_same"]
|
||||
LL | | fn both_names_different(x: i16);
|
||||
@ -58,7 +58,7 @@ LL | | fn other_both_names_different(x: u32);
|
||||
found `unsafe extern "C" fn(u32)`
|
||||
|
||||
warning: `different_mod` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:72:9
|
||||
--> $DIR/clashing-extern-fn.rs:73:9
|
||||
|
|
||||
LL | fn different_mod(x: u8);
|
||||
| ------------------------ `different_mod` previously declared here
|
||||
@ -70,7 +70,7 @@ LL | fn different_mod(x: u64);
|
||||
found `unsafe extern "C" fn(u64)`
|
||||
|
||||
warning: `variadic_decl` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:82:9
|
||||
--> $DIR/clashing-extern-fn.rs:83:9
|
||||
|
|
||||
LL | fn variadic_decl(x: u8, ...);
|
||||
| ----------------------------- `variadic_decl` previously declared here
|
||||
@ -82,7 +82,7 @@ LL | fn variadic_decl(x: u8);
|
||||
found `unsafe extern "C" fn(u8)`
|
||||
|
||||
warning: `weigh_banana` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:142:13
|
||||
--> $DIR/clashing-extern-fn.rs:143:13
|
||||
|
|
||||
LL | fn weigh_banana(count: *const Banana) -> u64;
|
||||
| --------------------------------------------- `weigh_banana` previously declared here
|
||||
@ -94,7 +94,7 @@ LL | fn weigh_banana(count: *const Banana) -> u64;
|
||||
found `unsafe extern "C" fn(*const three::Banana) -> u64`
|
||||
|
||||
warning: `draw_point` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:171:13
|
||||
--> $DIR/clashing-extern-fn.rs:172:13
|
||||
|
|
||||
LL | fn draw_point(p: Point);
|
||||
| ------------------------ `draw_point` previously declared here
|
||||
@ -106,7 +106,7 @@ LL | fn draw_point(p: Point);
|
||||
found `unsafe extern "C" fn(sameish_members::b::Point)`
|
||||
|
||||
warning: `origin` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:197:13
|
||||
--> $DIR/clashing-extern-fn.rs:198:13
|
||||
|
|
||||
LL | fn origin() -> Point3;
|
||||
| ---------------------- `origin` previously declared here
|
||||
@ -118,7 +118,7 @@ LL | fn origin() -> Point3;
|
||||
found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3`
|
||||
|
||||
warning: `transparent_incorrect` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:220:13
|
||||
--> $DIR/clashing-extern-fn.rs:221:13
|
||||
|
|
||||
LL | fn transparent_incorrect() -> T;
|
||||
| -------------------------------- `transparent_incorrect` previously declared here
|
||||
@ -130,7 +130,7 @@ LL | fn transparent_incorrect() -> isize;
|
||||
found `unsafe extern "C" fn() -> isize`
|
||||
|
||||
warning: `missing_return_type` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:238:13
|
||||
--> $DIR/clashing-extern-fn.rs:239:13
|
||||
|
|
||||
LL | fn missing_return_type() -> usize;
|
||||
| ---------------------------------- `missing_return_type` previously declared here
|
||||
@ -142,7 +142,7 @@ LL | fn missing_return_type();
|
||||
found `unsafe extern "C" fn()`
|
||||
|
||||
warning: `non_zero_usize` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:256:13
|
||||
--> $DIR/clashing-extern-fn.rs:257:13
|
||||
|
|
||||
LL | fn non_zero_usize() -> core::num::NonZeroUsize;
|
||||
| ----------------------------------------------- `non_zero_usize` previously declared here
|
||||
@ -154,7 +154,7 @@ LL | fn non_zero_usize() -> usize;
|
||||
found `unsafe extern "C" fn() -> usize`
|
||||
|
||||
warning: `non_null_ptr` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:258:13
|
||||
--> $DIR/clashing-extern-fn.rs:259:13
|
||||
|
|
||||
LL | fn non_null_ptr() -> core::ptr::NonNull<usize>;
|
||||
| ----------------------------------------------- `non_null_ptr` previously declared here
|
||||
@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize;
|
||||
found `unsafe extern "C" fn() -> *const usize`
|
||||
|
||||
warning: `option_non_zero_usize_incorrect` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:356:13
|
||||
--> $DIR/clashing-extern-fn.rs:357:13
|
||||
|
|
||||
LL | fn option_non_zero_usize_incorrect() -> usize;
|
||||
| ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here
|
||||
@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize;
|
||||
found `unsafe extern "C" fn() -> isize`
|
||||
|
||||
warning: `option_non_null_ptr_incorrect` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:358:13
|
||||
--> $DIR/clashing-extern-fn.rs:359:13
|
||||
|
|
||||
LL | fn option_non_null_ptr_incorrect() -> *const usize;
|
||||
| --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here
|
||||
@ -189,5 +189,48 @@ LL | fn option_non_null_ptr_incorrect() -> *const isize;
|
||||
= note: expected `unsafe extern "C" fn() -> *const usize`
|
||||
found `unsafe extern "C" fn() -> *const isize`
|
||||
|
||||
warning: 15 warnings emitted
|
||||
warning: `hidden_niche_transparent_no_niche` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:410:13
|
||||
|
|
||||
LL | fn hidden_niche_transparent_no_niche() -> usize;
|
||||
| ------------------------------------------------ `hidden_niche_transparent_no_niche` previously declared here
|
||||
...
|
||||
LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
|
|
||||
= note: expected `unsafe extern "C" fn() -> usize`
|
||||
found `unsafe extern "C" fn() -> Option<TransparentNoNiche>`
|
||||
|
||||
warning: `hidden_niche_unsafe_cell` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:414:13
|
||||
|
|
||||
LL | fn hidden_niche_unsafe_cell() -> usize;
|
||||
| --------------------------------------- `hidden_niche_unsafe_cell` previously declared here
|
||||
...
|
||||
LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
|
|
||||
= note: expected `unsafe extern "C" fn() -> usize`
|
||||
found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZeroUsize>>`
|
||||
|
||||
warning: `extern` block uses type `Option<TransparentNoNiche>`, which is not FFI-safe
|
||||
--> $DIR/clashing-extern-fn.rs:410:55
|
||||
|
|
||||
LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= note: `#[warn(improper_ctypes)]` on by default
|
||||
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
|
||||
= note: enum has no representation hint
|
||||
|
||||
warning: `extern` block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe
|
||||
--> $DIR/clashing-extern-fn.rs:414:46
|
||||
|
|
||||
LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
|
||||
= note: enum has no representation hint
|
||||
|
||||
warning: 19 warnings emitted
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
extern crate libc;
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
trait Bar { }
|
||||
@ -70,6 +71,11 @@ extern "C" {
|
||||
pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>`
|
||||
pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]`
|
||||
|
||||
pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>);
|
||||
//~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>`
|
||||
pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
|
||||
//~^ ERROR: uses type `Option<UnsafeCell<&i32>>`
|
||||
|
||||
pub static static_u128_type: u128; //~ ERROR: uses type `u128`
|
||||
pub static static_u128_array_type: [u128; 16]; //~ ERROR: uses type `u128`
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `extern` block uses type `Foo`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:47:28
|
||||
--> $DIR/lint-ctypes.rs:48:28
|
||||
|
|
||||
LL | pub fn ptr_type1(size: *const Foo);
|
||||
| ^^^^^^^^^^ not FFI-safe
|
||||
@ -12,13 +12,13 @@ LL | #![deny(improper_ctypes)]
|
||||
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
|
||||
= note: this struct has unspecified layout
|
||||
note: the type is defined here
|
||||
--> $DIR/lint-ctypes.rs:25:1
|
||||
--> $DIR/lint-ctypes.rs:26:1
|
||||
|
|
||||
LL | pub struct Foo;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `Foo`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:48:28
|
||||
--> $DIR/lint-ctypes.rs:49:28
|
||||
|
|
||||
LL | pub fn ptr_type2(size: *const Foo);
|
||||
| ^^^^^^^^^^ not FFI-safe
|
||||
@ -26,13 +26,13 @@ LL | pub fn ptr_type2(size: *const Foo);
|
||||
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
|
||||
= note: this struct has unspecified layout
|
||||
note: the type is defined here
|
||||
--> $DIR/lint-ctypes.rs:25:1
|
||||
--> $DIR/lint-ctypes.rs:26:1
|
||||
|
|
||||
LL | pub struct Foo;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `[u32]`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:49:26
|
||||
--> $DIR/lint-ctypes.rs:50:26
|
||||
|
|
||||
LL | pub fn slice_type(p: &[u32]);
|
||||
| ^^^^^^ not FFI-safe
|
||||
@ -41,7 +41,7 @@ LL | pub fn slice_type(p: &[u32]);
|
||||
= note: slices have no C equivalent
|
||||
|
||||
error: `extern` block uses type `str`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:50:24
|
||||
--> $DIR/lint-ctypes.rs:51:24
|
||||
|
|
||||
LL | pub fn str_type(p: &str);
|
||||
| ^^^^ not FFI-safe
|
||||
@ -50,7 +50,7 @@ LL | pub fn str_type(p: &str);
|
||||
= note: string slices have no C equivalent
|
||||
|
||||
error: `extern` block uses type `Box<u32>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:51:24
|
||||
--> $DIR/lint-ctypes.rs:52:24
|
||||
|
|
||||
LL | pub fn box_type(p: Box<u32>);
|
||||
| ^^^^^^^^ not FFI-safe
|
||||
@ -59,7 +59,7 @@ LL | pub fn box_type(p: Box<u32>);
|
||||
= note: this struct has unspecified layout
|
||||
|
||||
error: `extern` block uses type `Option<Box<u32>>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:52:28
|
||||
--> $DIR/lint-ctypes.rs:53:28
|
||||
|
|
||||
LL | pub fn opt_box_type(p: Option<Box<u32>>);
|
||||
| ^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
@ -68,7 +68,7 @@ LL | pub fn opt_box_type(p: Option<Box<u32>>);
|
||||
= note: enum has no representation hint
|
||||
|
||||
error: `extern` block uses type `char`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:54:25
|
||||
--> $DIR/lint-ctypes.rs:55:25
|
||||
|
|
||||
LL | pub fn char_type(p: char);
|
||||
| ^^^^ not FFI-safe
|
||||
@ -77,7 +77,7 @@ LL | pub fn char_type(p: char);
|
||||
= note: the `char` type has no C equivalent
|
||||
|
||||
error: `extern` block uses type `i128`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:55:25
|
||||
--> $DIR/lint-ctypes.rs:56:25
|
||||
|
|
||||
LL | pub fn i128_type(p: i128);
|
||||
| ^^^^ not FFI-safe
|
||||
@ -85,7 +85,7 @@ LL | pub fn i128_type(p: i128);
|
||||
= note: 128-bit integers don't currently have a known stable ABI
|
||||
|
||||
error: `extern` block uses type `u128`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:56:25
|
||||
--> $DIR/lint-ctypes.rs:57:25
|
||||
|
|
||||
LL | pub fn u128_type(p: u128);
|
||||
| ^^^^ not FFI-safe
|
||||
@ -93,7 +93,7 @@ LL | pub fn u128_type(p: u128);
|
||||
= note: 128-bit integers don't currently have a known stable ABI
|
||||
|
||||
error: `extern` block uses type `dyn Bar`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:57:26
|
||||
--> $DIR/lint-ctypes.rs:58:26
|
||||
|
|
||||
LL | pub fn trait_type(p: &dyn Bar);
|
||||
| ^^^^^^^^ not FFI-safe
|
||||
@ -101,7 +101,7 @@ LL | pub fn trait_type(p: &dyn Bar);
|
||||
= note: trait objects have no C equivalent
|
||||
|
||||
error: `extern` block uses type `(i32, i32)`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:58:26
|
||||
--> $DIR/lint-ctypes.rs:59:26
|
||||
|
|
||||
LL | pub fn tuple_type(p: (i32, i32));
|
||||
| ^^^^^^^^^^ not FFI-safe
|
||||
@ -110,7 +110,7 @@ LL | pub fn tuple_type(p: (i32, i32));
|
||||
= note: tuples have unspecified layout
|
||||
|
||||
error: `extern` block uses type `(i32, i32)`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:59:27
|
||||
--> $DIR/lint-ctypes.rs:60:27
|
||||
|
|
||||
LL | pub fn tuple_type2(p: I32Pair);
|
||||
| ^^^^^^^ not FFI-safe
|
||||
@ -119,7 +119,7 @@ LL | pub fn tuple_type2(p: I32Pair);
|
||||
= note: tuples have unspecified layout
|
||||
|
||||
error: `extern` block uses type `ZeroSize`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:60:25
|
||||
--> $DIR/lint-ctypes.rs:61:25
|
||||
|
|
||||
LL | pub fn zero_size(p: ZeroSize);
|
||||
| ^^^^^^^^ not FFI-safe
|
||||
@ -127,26 +127,26 @@ LL | pub fn zero_size(p: ZeroSize);
|
||||
= help: consider adding a member to this struct
|
||||
= note: this struct has no fields
|
||||
note: the type is defined here
|
||||
--> $DIR/lint-ctypes.rs:21:1
|
||||
--> $DIR/lint-ctypes.rs:22:1
|
||||
|
|
||||
LL | pub struct ZeroSize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `ZeroSizeWithPhantomData`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:61:33
|
||||
--> $DIR/lint-ctypes.rs:62:33
|
||||
|
|
||||
LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= note: composed only of `PhantomData`
|
||||
note: the type is defined here
|
||||
--> $DIR/lint-ctypes.rs:44:1
|
||||
--> $DIR/lint-ctypes.rs:45:1
|
||||
|
|
||||
LL | pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData<i32>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `PhantomData<bool>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:64:12
|
||||
--> $DIR/lint-ctypes.rs:65:12
|
||||
|
|
||||
LL | -> ::std::marker::PhantomData<bool>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
@ -154,7 +154,7 @@ LL | -> ::std::marker::PhantomData<bool>;
|
||||
= note: composed only of `PhantomData`
|
||||
|
||||
error: `extern` block uses type `fn()`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:65:23
|
||||
--> $DIR/lint-ctypes.rs:66:23
|
||||
|
|
||||
LL | pub fn fn_type(p: RustFn);
|
||||
| ^^^^^^ not FFI-safe
|
||||
@ -163,7 +163,7 @@ LL | pub fn fn_type(p: RustFn);
|
||||
= note: this function pointer has Rust-specific calling convention
|
||||
|
||||
error: `extern` block uses type `fn()`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:66:24
|
||||
--> $DIR/lint-ctypes.rs:67:24
|
||||
|
|
||||
LL | pub fn fn_type2(p: fn());
|
||||
| ^^^^ not FFI-safe
|
||||
@ -172,7 +172,7 @@ LL | pub fn fn_type2(p: fn());
|
||||
= note: this function pointer has Rust-specific calling convention
|
||||
|
||||
error: `extern` block uses type `Box<u32>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:67:28
|
||||
--> $DIR/lint-ctypes.rs:68:28
|
||||
|
|
||||
LL | pub fn fn_contained(p: RustBadRet);
|
||||
| ^^^^^^^^^^ not FFI-safe
|
||||
@ -181,7 +181,7 @@ LL | pub fn fn_contained(p: RustBadRet);
|
||||
= note: this struct has unspecified layout
|
||||
|
||||
error: `extern` block uses type `i128`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:68:32
|
||||
--> $DIR/lint-ctypes.rs:69:32
|
||||
|
|
||||
LL | pub fn transparent_i128(p: TransparentI128);
|
||||
| ^^^^^^^^^^^^^^^ not FFI-safe
|
||||
@ -189,7 +189,7 @@ LL | pub fn transparent_i128(p: TransparentI128);
|
||||
= note: 128-bit integers don't currently have a known stable ABI
|
||||
|
||||
error: `extern` block uses type `str`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:69:31
|
||||
--> $DIR/lint-ctypes.rs:70:31
|
||||
|
|
||||
LL | pub fn transparent_str(p: TransparentStr);
|
||||
| ^^^^^^^^^^^^^^ not FFI-safe
|
||||
@ -198,7 +198,7 @@ LL | pub fn transparent_str(p: TransparentStr);
|
||||
= note: string slices have no C equivalent
|
||||
|
||||
error: `extern` block uses type `Box<u32>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:70:30
|
||||
--> $DIR/lint-ctypes.rs:71:30
|
||||
|
|
||||
LL | pub fn transparent_fn(p: TransparentBadFn);
|
||||
| ^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
@ -207,7 +207,7 @@ LL | pub fn transparent_fn(p: TransparentBadFn);
|
||||
= note: this struct has unspecified layout
|
||||
|
||||
error: `extern` block uses type `[u8; 8]`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:71:27
|
||||
--> $DIR/lint-ctypes.rs:72:27
|
||||
|
|
||||
LL | pub fn raw_array(arr: [u8; 8]);
|
||||
| ^^^^^^^ not FFI-safe
|
||||
@ -215,8 +215,26 @@ LL | pub fn raw_array(arr: [u8; 8]);
|
||||
= help: consider passing a pointer to the array
|
||||
= note: passing raw arrays by value is not FFI-safe
|
||||
|
||||
error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:74:26
|
||||
|
|
||||
LL | pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
|
||||
= note: enum has no representation hint
|
||||
|
||||
error: `extern` block uses type `Option<UnsafeCell<&i32>>`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:76:26
|
||||
|
|
||||
LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
|
||||
= note: enum has no representation hint
|
||||
|
||||
error: `extern` block uses type `u128`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:73:34
|
||||
--> $DIR/lint-ctypes.rs:79:34
|
||||
|
|
||||
LL | pub static static_u128_type: u128;
|
||||
| ^^^^ not FFI-safe
|
||||
@ -224,12 +242,12 @@ LL | pub static static_u128_type: u128;
|
||||
= note: 128-bit integers don't currently have a known stable ABI
|
||||
|
||||
error: `extern` block uses type `u128`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes.rs:74:40
|
||||
--> $DIR/lint-ctypes.rs:80:40
|
||||
|
|
||||
LL | pub static static_u128_array_type: [u128; 16];
|
||||
| ^^^^^^^^^^ not FFI-safe
|
||||
|
|
||||
= note: 128-bit integers don't currently have a known stable ABI
|
||||
|
||||
error: aborting due to 24 previous errors
|
||||
error: aborting due to 26 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user