]>
Commit | Line | Data |
---|---|---|
0731742a | 1 | #![feature(rustc_private)] |
223e47cc | 2 | |
0bf4aa26 | 3 | #![allow(private_in_public)] |
e1599b0c | 4 | #![deny(improper_ctypes)] |
0bf4aa26 | 5 | |
1a4d82fc | 6 | extern crate libc; |
223e47cc | 7 | |
6a06907d | 8 | use std::cell::UnsafeCell; |
2c00a5a8 XL |
9 | use std::marker::PhantomData; |
10 | ||
3dfed10e | 11 | trait Bar { } |
7453a54e SL |
12 | trait Mirror { type It: ?Sized; } |
13 | impl<T: ?Sized> Mirror for T { type It = Self; } | |
c1a9b12d SL |
14 | #[repr(C)] |
15 | pub struct StructWithProjection(*mut <StructWithProjection as Mirror>::It); | |
16 | #[repr(C)] | |
17 | pub struct StructWithProjectionAndLifetime<'a>( | |
18 | &'a mut <StructWithProjectionAndLifetime<'a> as Mirror>::It | |
19 | ); | |
20 | pub type I32Pair = (i32, i32); | |
21 | #[repr(C)] | |
22 | pub struct ZeroSize; | |
23 | pub type RustFn = fn(); | |
5869c6ff | 24 | pub type RustBadRet = extern "C" fn() -> Box<u32>; |
c1a9b12d | 25 | pub type CVoidRet = (); |
e9174d1e | 26 | pub struct Foo; |
2c00a5a8 XL |
27 | #[repr(transparent)] |
28 | pub struct TransparentI128(i128); | |
29 | #[repr(transparent)] | |
30 | pub struct TransparentStr(&'static str); | |
31 | #[repr(transparent)] | |
32 | pub struct TransparentBadFn(RustBadRet); | |
33 | #[repr(transparent)] | |
34 | pub struct TransparentInt(u32); | |
35 | #[repr(transparent)] | |
36 | pub struct TransparentRef<'a>(&'a TransparentInt); | |
37 | #[repr(transparent)] | |
38 | pub struct TransparentLifetime<'a>(*const u8, PhantomData<&'a ()>); | |
39 | #[repr(transparent)] | |
40 | pub struct TransparentUnit<U>(f32, PhantomData<U>); | |
41 | #[repr(transparent)] | |
42 | pub struct TransparentCustomZst(i32, ZeroSize); | |
c1a9b12d | 43 | |
8bb4bdeb XL |
44 | #[repr(C)] |
45 | pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData<i32>); | |
46 | ||
5869c6ff | 47 | extern "C" { |
0531ce1d XL |
48 | pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo` |
49 | pub fn ptr_type2(size: *const Foo); //~ ERROR: uses type `Foo` | |
c295e0f8 XL |
50 | pub fn ptr_unit(p: *const ()); |
51 | pub fn ptr_tuple(p: *const ((),)); //~ ERROR: uses type `((),)` | |
0531ce1d XL |
52 | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` |
53 | pub fn str_type(p: &str); //~ ERROR: uses type `str` | |
1b1a35ee | 54 | pub fn box_type(p: Box<u32>); //~ ERROR uses type `Box<u32>` |
f9652781 | 55 | pub fn opt_box_type(p: Option<Box<u32>>); |
1b1a35ee | 56 | //~^ ERROR uses type `Option<Box<u32>>` |
0531ce1d XL |
57 | pub fn char_type(p: char); //~ ERROR uses type `char` |
58 | pub fn i128_type(p: i128); //~ ERROR uses type `i128` | |
59 | pub fn u128_type(p: u128); //~ ERROR uses type `u128` | |
3dfed10e | 60 | pub fn trait_type(p: &dyn Bar); //~ ERROR uses type `dyn Bar` |
0531ce1d XL |
61 | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` |
62 | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` | |
e1599b0c XL |
63 | pub fn zero_size(p: ZeroSize); //~ ERROR uses type `ZeroSize` |
64 | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); | |
65 | //~^ ERROR uses type `ZeroSizeWithPhantomData` | |
8bb4bdeb | 66 | pub fn zero_size_phantom_toplevel() |
1b1a35ee | 67 | -> ::std::marker::PhantomData<bool>; //~ ERROR uses type `PhantomData<bool>` |
e1599b0c XL |
68 | pub fn fn_type(p: RustFn); //~ ERROR uses type `fn()` |
69 | pub fn fn_type2(p: fn()); //~ ERROR uses type `fn()` | |
1b1a35ee | 70 | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `Box<u32>` |
0531ce1d XL |
71 | pub fn transparent_i128(p: TransparentI128); //~ ERROR: uses type `i128` |
72 | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` | |
1b1a35ee | 73 | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>` |
60c5eb7d XL |
74 | pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]` |
75 | ||
6a06907d XL |
76 | pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>); |
77 | //~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>` | |
78 | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); | |
79 | //~^ ERROR: uses type `Option<UnsafeCell<&i32>>` | |
80 | ||
60c5eb7d XL |
81 | pub static static_u128_type: u128; //~ ERROR: uses type `u128` |
82 | pub static static_u128_array_type: [u128; 16]; //~ ERROR: uses type `u128` | |
223e47cc | 83 | |
5869c6ff | 84 | pub fn good3(fptr: Option<extern "C" fn()>); |
c1a9b12d SL |
85 | pub fn good4(aptr: &[u8; 4 as usize]); |
86 | pub fn good5(s: StructWithProjection); | |
87 | pub fn good6(s: StructWithProjectionAndLifetime); | |
5869c6ff XL |
88 | pub fn good7(fptr: extern "C" fn() -> ()); |
89 | pub fn good8(fptr: extern "C" fn() -> !); | |
c1a9b12d SL |
90 | pub fn good9() -> (); |
91 | pub fn good10() -> CVoidRet; | |
e9174d1e SL |
92 | pub fn good11(size: isize); |
93 | pub fn good12(size: usize); | |
2c00a5a8 XL |
94 | pub fn good13(n: TransparentInt); |
95 | pub fn good14(p: TransparentRef); | |
96 | pub fn good15(p: TransparentLifetime); | |
97 | pub fn good16(p: TransparentUnit<ZeroSize>); | |
98 | pub fn good17(p: TransparentCustomZst); | |
b7449926 XL |
99 | #[allow(improper_ctypes)] |
100 | pub fn good18(_: &String); | |
60c5eb7d XL |
101 | pub fn good20(arr: *const [u8; 8]); |
102 | pub static good21: [u8; 8]; | |
103 | ||
b7449926 XL |
104 | } |
105 | ||
106 | #[allow(improper_ctypes)] | |
5869c6ff | 107 | extern "C" { |
b7449926 | 108 | pub fn good19(_: &String); |
1a4d82fc | 109 | } |
223e47cc | 110 | |
ff7c6d11 | 111 | #[cfg(not(target_arch = "wasm32"))] |
5869c6ff | 112 | extern "C" { |
ff7c6d11 XL |
113 | pub fn good1(size: *const libc::c_int); |
114 | pub fn good2(size: *const libc::c_uint); | |
115 | } | |
116 | ||
1a4d82fc | 117 | fn main() { |
223e47cc | 118 | } |