Skip to content

Commit 1f0e1a0

Browse files
author
Robin Kruppe
committed
Convert compile-fail/lint-ctypes.rs to ui test
1 parent 1670a53 commit 1f0e1a0

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed
File renamed without changes.

src/test/ui/lint-ctypes.stderr

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
error: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
2+
--> $DIR/lint-ctypes.rs:54:28
3+
|
4+
54 | pub fn ptr_type1(size: *const Foo); //~ ERROR: found struct without
5+
| ^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/lint-ctypes.rs:11:9
9+
|
10+
11 | #![deny(improper_ctypes)]
11+
| ^^^^^^^^^^^^^^^
12+
13+
error: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
14+
--> $DIR/lint-ctypes.rs:55:28
15+
|
16+
55 | pub fn ptr_type2(size: *const Foo); //~ ERROR: found struct without
17+
| ^^^^^^^^^^
18+
19+
error: found Rust slice type in foreign module, consider using a raw pointer instead
20+
--> $DIR/lint-ctypes.rs:56:26
21+
|
22+
56 | pub fn slice_type(p: &[u32]); //~ ERROR: found Rust slice type
23+
| ^^^^^^
24+
25+
error: found Rust type `str` in foreign module; consider using a `*const libc::c_char`
26+
--> $DIR/lint-ctypes.rs:57:24
27+
|
28+
57 | pub fn str_type(p: &str); //~ ERROR: found Rust type
29+
| ^^^^
30+
31+
error: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
32+
--> $DIR/lint-ctypes.rs:58:24
33+
|
34+
58 | pub fn box_type(p: Box<u32>); //~ ERROR found struct without
35+
| ^^^^^^^^
36+
37+
error: found Rust type `char` in foreign module, while `u32` or `libc::wchar_t` should be used
38+
--> $DIR/lint-ctypes.rs:59:25
39+
|
40+
59 | pub fn char_type(p: char); //~ ERROR found Rust type
41+
| ^^^^
42+
43+
error: found Rust type `i128` in foreign module, but 128-bit integers don't currently have a known stable ABI
44+
--> $DIR/lint-ctypes.rs:60:25
45+
|
46+
60 | pub fn i128_type(p: i128); //~ ERROR found Rust type
47+
| ^^^^
48+
49+
error: found Rust type `u128` in foreign module, but 128-bit integers don't currently have a known stable ABI
50+
--> $DIR/lint-ctypes.rs:61:25
51+
|
52+
61 | pub fn u128_type(p: u128); //~ ERROR found Rust type
53+
| ^^^^
54+
55+
error: found Rust trait type in foreign module, consider using a raw pointer instead
56+
--> $DIR/lint-ctypes.rs:62:26
57+
|
58+
62 | pub fn trait_type(p: &Clone); //~ ERROR found Rust trait type
59+
| ^^^^^^
60+
61+
error: found Rust tuple type in foreign module; consider using a struct instead
62+
--> $DIR/lint-ctypes.rs:63:26
63+
|
64+
63 | pub fn tuple_type(p: (i32, i32)); //~ ERROR found Rust tuple type
65+
| ^^^^^^^^^^
66+
67+
error: found Rust tuple type in foreign module; consider using a struct instead
68+
--> $DIR/lint-ctypes.rs:64:27
69+
|
70+
64 | pub fn tuple_type2(p: I32Pair); //~ ERROR found Rust tuple type
71+
| ^^^^^^^
72+
73+
error: found zero-size struct in foreign module, consider adding a member to this struct
74+
--> $DIR/lint-ctypes.rs:65:25
75+
|
76+
65 | pub fn zero_size(p: ZeroSize); //~ ERROR found zero-size struct
77+
| ^^^^^^^^
78+
79+
error: found zero-sized type composed only of phantom-data in a foreign-function.
80+
--> $DIR/lint-ctypes.rs:66:33
81+
|
82+
66 | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); //~ ERROR found zero-sized type
83+
| ^^^^^^^^^^^^^^^^^^^^^^^
84+
85+
error: found zero-sized type composed only of phantom-data in a foreign-function.
86+
--> $DIR/lint-ctypes.rs:68:12
87+
|
88+
68 | -> ::std::marker::PhantomData<bool>; //~ ERROR: found zero-sized type
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
90+
91+
error: found function pointer with Rust calling convention in foreign module; consider using an `extern` function pointer
92+
--> $DIR/lint-ctypes.rs:69:23
93+
|
94+
69 | pub fn fn_type(p: RustFn); //~ ERROR found function pointer with Rust
95+
| ^^^^^^
96+
97+
error: found function pointer with Rust calling convention in foreign module; consider using an `extern` function pointer
98+
--> $DIR/lint-ctypes.rs:70:24
99+
|
100+
70 | pub fn fn_type2(p: fn()); //~ ERROR found function pointer with Rust
101+
| ^^^^
102+
103+
error: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
104+
--> $DIR/lint-ctypes.rs:71:28
105+
|
106+
71 | pub fn fn_contained(p: RustBadRet); //~ ERROR: found struct without
107+
| ^^^^^^^^^^
108+
109+
error: found non-foreign-function-safe member in struct marked #[repr(C)]: found Rust type `i128` in foreign module, but 128-bit integers don't currently have a known stable ABI
110+
--> $DIR/lint-ctypes.rs:72:32
111+
|
112+
72 | pub fn transparent_i128(p: TransparentI128); //~ ERROR: found Rust type `i128`
113+
| ^^^^^^^^^^^^^^^
114+
115+
error: found non-foreign-function-safe member in struct marked #[repr(C)]: found Rust type `str` in foreign module; consider using a `*const libc::c_char`
116+
--> $DIR/lint-ctypes.rs:73:31
117+
|
118+
73 | pub fn transparent_str(p: TransparentStr); //~ ERROR: found Rust type `str`
119+
| ^^^^^^^^^^^^^^
120+
121+
error: found non-foreign-function-safe member in struct marked #[repr(C)]: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
122+
--> $DIR/lint-ctypes.rs:74:30
123+
|
124+
74 | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: found struct without
125+
| ^^^^^^^^^^^^^^^^
126+
127+
error: aborting due to 20 previous errors
128+

0 commit comments

Comments
 (0)