1 #![feature(rustc_private)]
3 #![allow(private_in_public)]
4 #![deny(improper_ctypes)]
8 use std
::cell
::UnsafeCell
;
9 use std
::marker
::PhantomData
;
12 trait Mirror { type It: ?Sized; }
13 impl<T
: ?Sized
> Mirror
for T { type It = Self; }
15 pub struct StructWithProjection(*mut <StructWithProjection
as Mirror
>::It
);
17 pub struct StructWithProjectionAndLifetime
<'a
>(
18 &'a
mut <StructWithProjectionAndLifetime
<'a
> as Mirror
>::It
20 pub type I32Pair
= (i32, i32);
23 pub type RustFn
= fn();
24 pub type RustBadRet
= extern "C" fn() -> Box
<u32>;
25 pub type CVoidRet
= ();
28 pub struct TransparentI128(i128
);
30 pub struct TransparentStr(&'
static str);
32 pub struct TransparentBadFn(RustBadRet
);
34 pub struct TransparentInt(u32);
36 pub struct TransparentRef
<'a
>(&'a TransparentInt
);
38 pub struct TransparentLifetime
<'a
>(*const u8, PhantomData
<&'
a ()>);
40 pub struct TransparentUnit
<U
>(f32, PhantomData
<U
>);
42 pub struct TransparentCustomZst(i32, ZeroSize
);
45 pub struct ZeroSizeWithPhantomData(::std
::marker
::PhantomData
<i32>);
48 pub fn ptr_type1(size
: *const Foo
); //~ ERROR: uses type `Foo`
49 pub fn ptr_type2(size
: *const Foo
); //~ ERROR: uses type `Foo`
50 pub fn slice_type(p
: &[u32]); //~ ERROR: uses type `[u32]`
51 pub fn str_type(p
: &str); //~ ERROR: uses type `str`
52 pub fn box_type(p
: Box
<u32>); //~ ERROR uses type `Box<u32>`
53 pub fn opt_box_type(p
: Option
<Box
<u32>>);
54 //~^ ERROR uses type `Option<Box<u32>>`
55 pub fn char_type(p
: char); //~ ERROR uses type `char`
56 pub fn i128_type(p
: i128
); //~ ERROR uses type `i128`
57 pub fn u128_type(p
: u128
); //~ ERROR uses type `u128`
58 pub fn trait_type(p
: &dyn Bar
); //~ ERROR uses type `dyn Bar`
59 pub fn tuple_type(p
: (i32, i32)); //~ ERROR uses type `(i32, i32)`
60 pub fn tuple_type2(p
: I32Pair
); //~ ERROR uses type `(i32, i32)`
61 pub fn zero_size(p
: ZeroSize
); //~ ERROR uses type `ZeroSize`
62 pub fn zero_size_phantom(p
: ZeroSizeWithPhantomData
);
63 //~^ ERROR uses type `ZeroSizeWithPhantomData`
64 pub fn zero_size_phantom_toplevel()
65 -> ::std
::marker
::PhantomData
<bool
>; //~ ERROR uses type `PhantomData<bool>`
66 pub fn fn_type(p
: RustFn
); //~ ERROR uses type `fn()`
67 pub fn fn_type2(p
: fn()); //~ ERROR uses type `fn()`
68 pub fn fn_contained(p
: RustBadRet
); //~ ERROR: uses type `Box<u32>`
69 pub fn transparent_i128(p
: TransparentI128
); //~ ERROR: uses type `i128`
70 pub fn transparent_str(p
: TransparentStr
); //~ ERROR: uses type `str`
71 pub fn transparent_fn(p
: TransparentBadFn
); //~ ERROR: uses type `Box<u32>`
72 pub fn raw_array(arr
: [u8; 8]); //~ ERROR: uses type `[u8; 8]`
74 pub fn no_niche_a(a
: Option
<UnsafeCell
<extern fn()>>);
75 //~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>`
76 pub fn no_niche_b(b
: Option
<UnsafeCell
<&i32>>);
77 //~^ ERROR: uses type `Option<UnsafeCell<&i32>>`
79 pub static static_u128_type
: u128
; //~ ERROR: uses type `u128`
80 pub static static_u128_array_type
: [u128
; 16]; //~ ERROR: uses type `u128`
82 pub fn good3(fptr
: Option
<extern "C" fn()>);
83 pub fn good4(aptr
: &[u8; 4 as usize]);
84 pub fn good5(s
: StructWithProjection
);
85 pub fn good6(s
: StructWithProjectionAndLifetime
);
86 pub fn good7(fptr
: extern "C" fn() -> ());
87 pub fn good8(fptr
: extern "C" fn() -> !);
89 pub fn good10() -> CVoidRet
;
90 pub fn good11(size
: isize);
91 pub fn good12(size
: usize);
92 pub fn good13(n
: TransparentInt
);
93 pub fn good14(p
: TransparentRef
);
94 pub fn good15(p
: TransparentLifetime
);
95 pub fn good16(p
: TransparentUnit
<ZeroSize
>);
96 pub fn good17(p
: TransparentCustomZst
);
97 #[allow(improper_ctypes)]
98 pub fn good18(_
: &String
);
99 pub fn good20(arr
: *const [u8; 8]);
100 pub static good21
: [u8; 8];
104 #[allow(improper_ctypes)]
106 pub fn good19(_
: &String
);
109 #[cfg(not(target_arch = "wasm32"))]
111 pub fn good1(size
: *const libc
::c_int
);
112 pub fn good2(size
: *const libc
::c_uint
);