Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit afa32e8

Browse files
committedJun 5, 2025
TEMP COMMIT, to be deleted on rebase: remove i128/u128 warnings
1 parent fa10bbd commit afa32e8

File tree

10 files changed

+47
-223
lines changed

10 files changed

+47
-223
lines changed
 

‎compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,6 @@ lint_improper_ctypes = {$desc} uses type `{$ty}`, which is not FFI-safe
374374
.label = not FFI-safe
375375
.note = the type is defined here
376376
377-
lint_improper_ctypes_128bit = 128-bit integers don't currently have a known stable ABI
378-
379377
lint_improper_ctypes_array_help = consider passing a pointer to the array
380378
381379
lint_improper_ctypes_array_reason = passing raw arrays by value is not FFI-safe

‎compiler/rustc_lint/src/types/improper_ctypes.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::cmp::{Eq, PartialEq};
33
use std::iter;
44
use std::ops::ControlFlow;
55

6-
use rustc_abi::{Integer, IntegerType, VariantIdx};
6+
use rustc_abi::VariantIdx;
77
use rustc_data_structures::fx::FxHashSet;
88
use rustc_errors::DiagMessage;
99
use rustc_hir::def::CtorKind;
@@ -582,11 +582,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
582582
}
583583

584584
/// Checks whether an uninhabited type (one without valid values) is safe-ish to have here
585-
fn visit_uninhabited(
586-
&self,
587-
state: CTypesVisitorState,
588-
ty: Ty<'tcx>,
589-
) -> FfiResult<'tcx> {
585+
fn visit_uninhabited(&self, state: CTypesVisitorState, ty: Ty<'tcx>) -> FfiResult<'tcx> {
590586
if state.is_in_function_return() {
591587
FfiResult::FfiSafe
592588
} else {
@@ -604,17 +600,16 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
604600
fn visit_numeric(&self, ty: Ty<'tcx>) -> FfiResult<'tcx> {
605601
// FIXME: for now, this is very incomplete, and seems to assume a x86_64 target
606602
match ty.kind() {
607-
ty::Int(ty::IntTy::I128) | ty::Uint(ty::UintTy::U128) => {
608-
FfiResult::new_with_reason(ty, fluent::lint_improper_ctypes_128bit, None)
609-
}
603+
// note: before rust 1.77, 128-bit ints were not FFI-safe on x86_64
604+
// ...they probably are still unsafe on i686 and other x86_32 architectures
610605
ty::Int(..) | ty::Uint(..) | ty::Float(..) => FfiResult::FfiSafe,
611606

612607
ty::Char => FfiResult::new_with_reason(
613608
ty,
614609
fluent::lint_improper_ctypes_char_reason,
615610
Some(fluent::lint_improper_ctypes_char_help),
616611
),
617-
_ => bug!("visit_numeric is to be called with numeric (int, float) types"),
612+
_ => bug!("visit_numeric is to be called with numeric (char, int, float) types"),
618613
}
619614
}
620615

@@ -984,9 +979,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
984979
);
985980
}
986981

987-
if let Some(IntegerType::Fixed(Integer::I128, _)) = def.repr().int {
988-
return FfiResult::new_with_reason(ty, fluent::lint_improper_ctypes_128bit, None);
989-
}
982+
// FIXME: connect `def.repr().int` to visit_numeric
983+
// (for now it's OK, `repr(char)` doesn't exist and visit_numeric doesn't warn on anything else)
990984

991985
let non_exhaustive = def.variant_list_has_applicable_non_exhaustive();
992986
// Check the contained variants.

‎tests/ui/asm/naked-functions-ffi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ use std::arch::naked_asm;
77
#[unsafe(naked)]
88
pub extern "C" fn naked(p: char) -> u128 {
99
//~^ WARN uses type `char`
10-
//~| WARN uses type `u128`
1110
naked_asm!("")
1211
}

‎tests/ui/asm/naked-functions-ffi.stderr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,5 @@ LL | pub extern "C" fn naked(p: char) -> u128 {
88
= note: the `char` type has no C equivalent
99
= note: `#[warn(improper_c_fn_definitions)]` on by default
1010

11-
warning: `extern` fn uses type `u128`, which is not FFI-safe
12-
--> $DIR/naked-functions-ffi.rs:8:37
13-
|
14-
LL | pub extern "C" fn naked(p: char) -> u128 {
15-
| ^^^^ not FFI-safe
16-
|
17-
= note: 128-bit integers don't currently have a known stable ABI
18-
19-
warning: 2 warnings emitted
11+
warning: 1 warning emitted
2012

‎tests/ui/lint/improper_ctypes/ctypes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ extern "C" {
7676
pub fn box_type(p: Box<u32>);
7777
pub fn opt_box_type(p: Option<Box<u32>>);
7878
pub fn char_type(p: char); //~ ERROR uses type `char`
79-
pub fn i128_type(p: i128); //~ ERROR uses type `i128`
80-
pub fn u128_type(p: u128); //~ ERROR uses type `u128`
79+
pub fn i128_type(p: i128);
80+
pub fn u128_type(p: u128);
8181
pub fn pat_type1() -> pattern_type!(u32 is 1..);
8282
pub fn pat_type2(p: pattern_type!(u32 is 1..)); // no error!
8383
pub fn trait_type(p: &dyn Bar); //~ ERROR uses type `&dyn Bar`
@@ -91,7 +91,7 @@ extern "C" {
9191
pub fn fn_type(p: RustFn); //~ ERROR uses type `fn()`
9292
pub fn fn_type2(p: fn()); //~ ERROR uses type `fn()`
9393
pub fn fn_contained(p: RustBoxRet);
94-
pub fn transparent_i128(p: TransparentI128); //~ ERROR: uses type `TransparentI128`
94+
pub fn transparent_i128(p: TransparentI128);
9595
pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `TransparentStr`
9696
pub fn transparent_fn(p: TransparentBoxFn);
9797
pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]`
@@ -110,8 +110,8 @@ extern "C" {
110110
pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
111111
//~^ ERROR: uses type `Option<UnsafeCell<&i32>>`
112112

113-
pub static static_u128_type: u128; //~ ERROR: uses type `u128`
114-
pub static static_u128_array_type: [u128; 16]; //~ ERROR: uses type `u128`
113+
pub static static_u128_type: u128;
114+
pub static static_u128_array_type: [u128; 16];
115115

116116
pub fn good3(fptr: Option<extern "C" fn()>);
117117
pub fn good4(aptr: &[u8; 4 as usize]);

‎tests/ui/lint/improper_ctypes/ctypes.stderr

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,6 @@ LL | pub fn char_type(p: char);
3030
= help: consider using `u32` or `libc::wchar_t` instead
3131
= note: the `char` type has no C equivalent
3232

33-
error: `extern` block uses type `i128`, which is not FFI-safe
34-
--> $DIR/ctypes.rs:79:25
35-
|
36-
LL | pub fn i128_type(p: i128);
37-
| ^^^^ not FFI-safe
38-
|
39-
= note: 128-bit integers don't currently have a known stable ABI
40-
41-
error: `extern` block uses type `u128`, which is not FFI-safe
42-
--> $DIR/ctypes.rs:80:25
43-
|
44-
LL | pub fn u128_type(p: u128);
45-
| ^^^^ not FFI-safe
46-
|
47-
= note: 128-bit integers don't currently have a known stable ABI
48-
4933
error: `extern` block uses type `&dyn Bar`, which is not FFI-safe
5034
--> $DIR/ctypes.rs:83:26
5135
|
@@ -125,20 +109,6 @@ LL | pub fn fn_type2(p: fn());
125109
= help: consider using an `extern fn(...) -> ...` function pointer instead
126110
= note: this function pointer has Rust-specific calling convention
127111

128-
error: `extern` block uses type `TransparentI128`, which is not FFI-safe
129-
--> $DIR/ctypes.rs:94:32
130-
|
131-
LL | pub fn transparent_i128(p: TransparentI128);
132-
| ^^^^^^^^^^^^^^^ not FFI-safe
133-
|
134-
= note: this struct/enum/union (`TransparentI128`) is FFI-unsafe due to a `i128` field
135-
note: the type is defined here
136-
--> $DIR/ctypes.rs:34:1
137-
|
138-
LL | pub struct TransparentI128(i128);
139-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
140-
= note: 128-bit integers don't currently have a known stable ABI
141-
142112
error: `extern` block uses type `TransparentStr`, which is not FFI-safe
143113
--> $DIR/ctypes.rs:95:31
144114
|
@@ -229,22 +199,6 @@ LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
229199
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
230200
= note: enum has no representation hint
231201

232-
error: `extern` block uses type `u128`, which is not FFI-safe
233-
--> $DIR/ctypes.rs:113:34
234-
|
235-
LL | pub static static_u128_type: u128;
236-
| ^^^^ not FFI-safe
237-
|
238-
= note: 128-bit integers don't currently have a known stable ABI
239-
240-
error: `extern` block uses type `u128`, which is not FFI-safe
241-
--> $DIR/ctypes.rs:114:40
242-
|
243-
LL | pub static static_u128_array_type: [u128; 16];
244-
| ^^^^^^^^^^ not FFI-safe
245-
|
246-
= note: 128-bit integers don't currently have a known stable ABI
247-
248202
error: foreign-code-reachable static uses type `&str`, which is not FFI-safe
249203
--> $DIR/ctypes.rs:147:29
250204
|
@@ -259,5 +213,5 @@ note: the lint level is defined here
259213
LL | #![deny(improper_c_fn_definitions, improper_c_var_definitions)]
260214
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
261215

262-
error: aborting due to 25 previous errors
216+
error: aborting due to 20 previous errors
263217

‎tests/ui/lint/improper_ctypes/lint-enum.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ extern "C" {
8484
fn repr_c(x: ReprC);
8585
fn repr_u8(x: U8);
8686
fn repr_isize(x: Isize);
87-
fn repr_u128(x: U128); //~ ERROR `extern` block uses type `U128`
88-
fn repr_i128(x: I128); //~ ERROR `extern` block uses type `I128`
87+
fn repr_u128(x: U128);
88+
fn repr_i128(x: I128);
8989
fn option_ref(x: Option<&'static u8>);
9090
fn option_fn(x: Option<extern "C" fn()>);
9191
fn option_nonnull(x: Option<std::ptr::NonNull<u8>>);
@@ -95,14 +95,12 @@ extern "C" {
9595
fn option_nonzero_u32(x: Option<num::NonZero<u32>>);
9696
fn option_nonzero_u64(x: Option<num::NonZero<u64>>);
9797
fn option_nonzero_u128(x: Option<num::NonZero<u128>>);
98-
//~^ ERROR `extern` block uses type `u128`
9998
fn option_nonzero_usize(x: Option<num::NonZero<usize>>);
10099
fn option_nonzero_i8(x: Option<num::NonZero<i8>>);
101100
fn option_nonzero_i16(x: Option<num::NonZero<i16>>);
102101
fn option_nonzero_i32(x: Option<num::NonZero<i32>>);
103102
fn option_nonzero_i64(x: Option<num::NonZero<i64>>);
104103
fn option_nonzero_i128(x: Option<num::NonZero<i128>>);
105-
//~^ ERROR `extern` block uses type `i128`
106104
fn option_nonzero_isize(x: Option<num::NonZero<isize>>);
107105
fn option_transparent_struct(x: Option<TransparentStruct<num::NonZero<u8>>>);
108106
fn option_transparent_enum(x: Option<TransparentEnum<num::NonZero<u8>>>);
@@ -120,14 +118,12 @@ extern "C" {
120118
fn result_nonzero_u32_t(x: Result<num::NonZero<u32>, ()>);
121119
fn result_nonzero_u64_t(x: Result<num::NonZero<u64>, ()>);
122120
fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>);
123-
//~^ ERROR `extern` block uses type `u128`
124121
fn result_nonzero_usize_t(x: Result<num::NonZero<usize>, ()>);
125122
fn result_nonzero_i8_t(x: Result<num::NonZero<i8>, ()>);
126123
fn result_nonzero_i16_t(x: Result<num::NonZero<i16>, ()>);
127124
fn result_nonzero_i32_t(x: Result<num::NonZero<i32>, ()>);
128125
fn result_nonzero_i64_t(x: Result<num::NonZero<i64>, ()>);
129126
fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>);
130-
//~^ ERROR `extern` block uses type `i128`
131127
fn result_nonzero_isize_t(x: Result<num::NonZero<isize>, ()>);
132128
fn result_transparent_struct_t(x: Result<TransparentStruct<num::NonZero<u8>>, ()>);
133129
fn result_transparent_enum_t(x: Result<TransparentEnum<num::NonZero<u8>>, ()>);
@@ -158,14 +154,12 @@ extern "C" {
158154
fn result_nonzero_u32_e(x: Result<(), num::NonZero<u32>>);
159155
fn result_nonzero_u64_e(x: Result<(), num::NonZero<u64>>);
160156
fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>);
161-
//~^ ERROR `extern` block uses type `u128`
162157
fn result_nonzero_usize_e(x: Result<(), num::NonZero<usize>>);
163158
fn result_nonzero_i8_e(x: Result<(), num::NonZero<i8>>);
164159
fn result_nonzero_i16_e(x: Result<(), num::NonZero<i16>>);
165160
fn result_nonzero_i32_e(x: Result<(), num::NonZero<i32>>);
166161
fn result_nonzero_i64_e(x: Result<(), num::NonZero<i64>>);
167162
fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>);
168-
//~^ ERROR `extern` block uses type `i128`
169163
fn result_nonzero_isize_e(x: Result<(), num::NonZero<isize>>);
170164
fn result_transparent_struct_e(x: Result<(), TransparentStruct<num::NonZero<u8>>>);
171165
fn result_transparent_enum_e(x: Result<(), TransparentEnum<num::NonZero<u8>>>);

‎tests/ui/lint/improper_ctypes/lint-enum.stderr

Lines changed: 19 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -58,50 +58,8 @@ note: the type is defined here
5858
LL | enum T {
5959
| ^^^^^^
6060

61-
error: `extern` block uses type `U128`, which is not FFI-safe
62-
--> $DIR/lint-enum.rs:87:21
63-
|
64-
LL | fn repr_u128(x: U128);
65-
| ^^^^ not FFI-safe
66-
|
67-
= note: 128-bit integers don't currently have a known stable ABI
68-
note: the type is defined here
69-
--> $DIR/lint-enum.rs:44:1
70-
|
71-
LL | enum U128 {
72-
| ^^^^^^^^^
73-
74-
error: `extern` block uses type `I128`, which is not FFI-safe
75-
--> $DIR/lint-enum.rs:88:21
76-
|
77-
LL | fn repr_i128(x: I128);
78-
| ^^^^ not FFI-safe
79-
|
80-
= note: 128-bit integers don't currently have a known stable ABI
81-
note: the type is defined here
82-
--> $DIR/lint-enum.rs:51:1
83-
|
84-
LL | enum I128 {
85-
| ^^^^^^^^^
86-
87-
error: `extern` block uses type `u128`, which is not FFI-safe
88-
--> $DIR/lint-enum.rs:97:31
89-
|
90-
LL | fn option_nonzero_u128(x: Option<num::NonZero<u128>>);
91-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
92-
|
93-
= note: 128-bit integers don't currently have a known stable ABI
94-
95-
error: `extern` block uses type `i128`, which is not FFI-safe
96-
--> $DIR/lint-enum.rs:104:31
97-
|
98-
LL | fn option_nonzero_i128(x: Option<num::NonZero<i128>>);
99-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
100-
|
101-
= note: 128-bit integers don't currently have a known stable ABI
102-
10361
error: `extern` block uses type `Option<TransparentUnion<NonZero<u8>>>`, which is not FFI-safe
104-
--> $DIR/lint-enum.rs:109:36
62+
--> $DIR/lint-enum.rs:107:36
10563
|
10664
LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8>>>);
10765
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -110,7 +68,7 @@ LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8>
11068
= note: enum has no representation hint
11169

11270
error: `extern` block uses type `Option<Rust<NonZero<u8>>>`, which is not FFI-safe
113-
--> $DIR/lint-enum.rs:111:28
71+
--> $DIR/lint-enum.rs:109:28
11472
|
11573
LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>);
11674
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -119,32 +77,16 @@ LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>);
11977
= note: enum has no representation hint
12078

12179
error: `extern` block uses type `Option<u8>`, which is not FFI-safe
122-
--> $DIR/lint-enum.rs:112:21
80+
--> $DIR/lint-enum.rs:110:21
12381
|
12482
LL | fn option_u8(x: Option<u8>);
12583
| ^^^^^^^^^^ not FFI-safe
12684
|
12785
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
12886
= note: enum has no representation hint
12987

130-
error: `extern` block uses type `u128`, which is not FFI-safe
131-
--> $DIR/lint-enum.rs:122:33
132-
|
133-
LL | fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>);
134-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
135-
|
136-
= note: 128-bit integers don't currently have a known stable ABI
137-
138-
error: `extern` block uses type `i128`, which is not FFI-safe
139-
--> $DIR/lint-enum.rs:129:33
140-
|
141-
LL | fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>);
142-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
143-
|
144-
= note: 128-bit integers don't currently have a known stable ABI
145-
14688
error: `extern` block uses type `Result<TransparentUnion<NonZero<u8>>, ()>`, which is not FFI-safe
147-
--> $DIR/lint-enum.rs:134:38
89+
--> $DIR/lint-enum.rs:130:38
14890
|
14991
LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u8>>, ()>);
15092
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -153,7 +95,7 @@ LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u
15395
= note: enum has no representation hint
15496

15597
error: `extern` block uses type `Result<Rust<NonZero<u8>>, ()>`, which is not FFI-safe
156-
--> $DIR/lint-enum.rs:136:30
98+
--> $DIR/lint-enum.rs:132:30
15799
|
158100
LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>);
159101
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -162,7 +104,7 @@ LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>);
162104
= note: enum has no representation hint
163105

164106
error: `extern` block uses type `Result<NonZero<u8>, U>`, which is not FFI-safe
165-
--> $DIR/lint-enum.rs:140:51
107+
--> $DIR/lint-enum.rs:136:51
166108
|
167109
LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, U>);
168110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -171,7 +113,7 @@ LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>,
171113
= note: enum has no representation hint
172114

173115
error: `extern` block uses type `Result<NonZero<u8>, B>`, which is not FFI-safe
174-
--> $DIR/lint-enum.rs:142:53
116+
--> $DIR/lint-enum.rs:138:53
175117
|
176118
LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8>, B>);
177119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -180,7 +122,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8>
180122
= note: enum has no representation hint
181123

182124
error: `extern` block uses type `Result<NonZero<u8>, NonExhaustive>`, which is not FFI-safe
183-
--> $DIR/lint-enum.rs:144:51
125+
--> $DIR/lint-enum.rs:140:51
184126
|
185127
LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, NonExhaustive>);
186128
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -189,7 +131,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>,
189131
= note: enum has no representation hint
190132

191133
error: `extern` block uses type `Result<NonZero<u8>, Field>`, which is not FFI-safe
192-
--> $DIR/lint-enum.rs:147:49
134+
--> $DIR/lint-enum.rs:143:49
193135
|
194136
LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Field>);
195137
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -198,32 +140,16 @@ LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Fi
198140
= note: enum has no representation hint
199141

200142
error: `extern` block uses type `Result<Result<(), NonZero<u8>>, ()>`, which is not FFI-safe
201-
--> $DIR/lint-enum.rs:149:30
143+
--> $DIR/lint-enum.rs:145:30
202144
|
203145
LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>);
204146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
205147
|
206148
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
207149
= note: enum has no representation hint
208150

209-
error: `extern` block uses type `u128`, which is not FFI-safe
210-
--> $DIR/lint-enum.rs:160:33
211-
|
212-
LL | fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>);
213-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
214-
|
215-
= note: 128-bit integers don't currently have a known stable ABI
216-
217-
error: `extern` block uses type `i128`, which is not FFI-safe
218-
--> $DIR/lint-enum.rs:167:33
219-
|
220-
LL | fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>);
221-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
222-
|
223-
= note: 128-bit integers don't currently have a known stable ABI
224-
225151
error: `extern` block uses type `Result<(), TransparentUnion<NonZero<u8>>>`, which is not FFI-safe
226-
--> $DIR/lint-enum.rs:172:38
152+
--> $DIR/lint-enum.rs:166:38
227153
|
228154
LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZero<u8>>>);
229155
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -232,7 +158,7 @@ LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZe
232158
= note: enum has no representation hint
233159

234160
error: `extern` block uses type `Result<(), Rust<NonZero<u8>>>`, which is not FFI-safe
235-
--> $DIR/lint-enum.rs:174:30
161+
--> $DIR/lint-enum.rs:168:30
236162
|
237163
LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>);
238164
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -241,7 +167,7 @@ LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>);
241167
= note: enum has no representation hint
242168

243169
error: `extern` block uses type `Result<U, NonZero<u8>>`, which is not FFI-safe
244-
--> $DIR/lint-enum.rs:178:51
170+
--> $DIR/lint-enum.rs:172:51
245171
|
246172
LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8>>);
247173
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -250,7 +176,7 @@ LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8
250176
= note: enum has no representation hint
251177

252178
error: `extern` block uses type `Result<B, NonZero<u8>>`, which is not FFI-safe
253-
--> $DIR/lint-enum.rs:180:53
179+
--> $DIR/lint-enum.rs:174:53
254180
|
255181
LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero<u8>>);
256182
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -259,7 +185,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero<
259185
= note: enum has no representation hint
260186

261187
error: `extern` block uses type `Result<NonExhaustive, NonZero<u8>>`, which is not FFI-safe
262-
--> $DIR/lint-enum.rs:182:51
188+
--> $DIR/lint-enum.rs:176:51
263189
|
264190
LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num::NonZero<u8>>);
265191
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -268,7 +194,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num
268194
= note: enum has no representation hint
269195

270196
error: `extern` block uses type `Result<Field, NonZero<u8>>`, which is not FFI-safe
271-
--> $DIR/lint-enum.rs:185:49
197+
--> $DIR/lint-enum.rs:179:49
272198
|
273199
LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero<u8>>);
274200
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -277,7 +203,7 @@ LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero<
277203
= note: enum has no representation hint
278204

279205
error: `extern` block uses type `Result<(), Result<(), NonZero<u8>>>`, which is not FFI-safe
280-
--> $DIR/lint-enum.rs:187:30
206+
--> $DIR/lint-enum.rs:181:30
281207
|
282208
LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>);
283209
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -286,13 +212,13 @@ LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>);
286212
= note: enum has no representation hint
287213

288214
error: `extern` block uses type `Result<(), ()>`, which is not FFI-safe
289-
--> $DIR/lint-enum.rs:189:27
215+
--> $DIR/lint-enum.rs:183:27
290216
|
291217
LL | fn result_unit_t_e(x: Result<(), ()>);
292218
| ^^^^^^^^^^^^^^ not FFI-safe
293219
|
294220
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
295221
= note: enum has no representation hint
296222

297-
error: aborting due to 30 previous errors
223+
error: aborting due to 22 previous errors
298224

‎tests/ui/lint/improper_ctypes/lint-fn.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ pub extern "C" fn char_type(p: char) { }
9292
//~^ ERROR uses type `char`
9393

9494
pub extern "C" fn i128_type(p: i128) { }
95-
//~^ ERROR uses type `i128`
9695

9796
pub extern "C" fn u128_type(p: u128) { }
98-
//~^ ERROR uses type `u128`
9997

10098
pub extern "C" fn tuple_type(p: (i32, i32)) { }
10199
//~^ ERROR uses type `(i32, i32)`
@@ -124,7 +122,6 @@ pub extern "C" fn fn_contained(p: RustBadRet) { }
124122
// ^ FIXME it doesn't see the error... but at least it reports it elsewhere?
125123

126124
pub extern "C" fn transparent_i128(p: TransparentI128) { }
127-
//~^ ERROR: uses type `TransparentI128`
128125

129126
pub extern "C" fn transparent_str(p: TransparentStr) { }
130127
//~^ ERROR: uses type `TransparentStr`

‎tests/ui/lint/improper_ctypes/lint-fn.stderr

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,8 @@ LL | pub extern "C" fn char_type(p: char) { }
7171
= help: consider using `u32` or `libc::wchar_t` instead
7272
= note: the `char` type has no C equivalent
7373

74-
error: `extern` fn uses type `i128`, which is not FFI-safe
75-
--> $DIR/lint-fn.rs:94:32
76-
|
77-
LL | pub extern "C" fn i128_type(p: i128) { }
78-
| ^^^^ not FFI-safe
79-
|
80-
= note: 128-bit integers don't currently have a known stable ABI
81-
82-
error: `extern` fn uses type `u128`, which is not FFI-safe
83-
--> $DIR/lint-fn.rs:97:32
84-
|
85-
LL | pub extern "C" fn u128_type(p: u128) { }
86-
| ^^^^ not FFI-safe
87-
|
88-
= note: 128-bit integers don't currently have a known stable ABI
89-
9074
error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe
91-
--> $DIR/lint-fn.rs:100:33
75+
--> $DIR/lint-fn.rs:98:33
9276
|
9377
LL | pub extern "C" fn tuple_type(p: (i32, i32)) { }
9478
| ^^^^^^^^^^ not FFI-safe
@@ -97,7 +81,7 @@ LL | pub extern "C" fn tuple_type(p: (i32, i32)) { }
9781
= note: tuples have unspecified layout
9882

9983
error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe
100-
--> $DIR/lint-fn.rs:103:34
84+
--> $DIR/lint-fn.rs:101:34
10185
|
10286
LL | pub extern "C" fn tuple_type2(p: I32Pair) { }
10387
| ^^^^^^^ not FFI-safe
@@ -106,7 +90,7 @@ LL | pub extern "C" fn tuple_type2(p: I32Pair) { }
10690
= note: tuples have unspecified layout
10791

10892
error: `extern` fn uses type `ZeroSize`, which is not FFI-safe
109-
--> $DIR/lint-fn.rs:106:32
93+
--> $DIR/lint-fn.rs:104:32
11094
|
11195
LL | pub extern "C" fn zero_size(p: ZeroSize) { }
11296
| ^^^^^^^^ not FFI-safe
@@ -120,7 +104,7 @@ LL | pub struct ZeroSize;
120104
| ^^^^^^^^^^^^^^^^^^^
121105

122106
error: `extern` fn uses type `ZeroSizeWithPhantomData`, which is not FFI-safe
123-
--> $DIR/lint-fn.rs:109:40
107+
--> $DIR/lint-fn.rs:107:40
124108
|
125109
LL | pub extern "C" fn zero_size_phantom(p: ZeroSizeWithPhantomData) { }
126110
| ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -133,15 +117,15 @@ LL | pub struct ZeroSizeWithPhantomData(PhantomData<i32>);
133117
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134118

135119
error: `extern` fn uses type `PhantomData<bool>`, which is not FFI-safe
136-
--> $DIR/lint-fn.rs:112:51
120+
--> $DIR/lint-fn.rs:110:51
137121
|
138122
LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData<bool> {
139123
| ^^^^^^^^^^^^^^^^^ not FFI-safe
140124
|
141125
= note: composed only of `PhantomData`
142126

143127
error: `extern` fn uses type `fn()`, which is not FFI-safe
144-
--> $DIR/lint-fn.rs:117:30
128+
--> $DIR/lint-fn.rs:115:30
145129
|
146130
LL | pub extern "C" fn fn_type(p: RustFn) { }
147131
| ^^^^^^ not FFI-safe
@@ -150,30 +134,16 @@ LL | pub extern "C" fn fn_type(p: RustFn) { }
150134
= note: this function pointer has Rust-specific calling convention
151135

152136
error: `extern` fn uses type `fn()`, which is not FFI-safe
153-
--> $DIR/lint-fn.rs:120:31
137+
--> $DIR/lint-fn.rs:118:31
154138
|
155139
LL | pub extern "C" fn fn_type2(p: fn()) { }
156140
| ^^^^ not FFI-safe
157141
|
158142
= help: consider using an `extern fn(...) -> ...` function pointer instead
159143
= note: this function pointer has Rust-specific calling convention
160144

161-
error: `extern` fn uses type `TransparentI128`, which is not FFI-safe
162-
--> $DIR/lint-fn.rs:126:39
163-
|
164-
LL | pub extern "C" fn transparent_i128(p: TransparentI128) { }
165-
| ^^^^^^^^^^^^^^^ not FFI-safe
166-
|
167-
= note: this struct/enum/union (`TransparentI128`) is FFI-unsafe due to a `i128` field
168-
note: the type is defined here
169-
--> $DIR/lint-fn.rs:37:1
170-
|
171-
LL | pub struct TransparentI128(i128);
172-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
173-
= note: 128-bit integers don't currently have a known stable ABI
174-
175145
error: `extern` fn uses type `TransparentStr`, which is not FFI-safe
176-
--> $DIR/lint-fn.rs:129:38
146+
--> $DIR/lint-fn.rs:126:38
177147
|
178148
LL | pub extern "C" fn transparent_str(p: TransparentStr) { }
179149
| ^^^^^^^^^^^^^^ not FFI-safe
@@ -188,15 +158,15 @@ LL | pub struct TransparentStr(&'static str);
188158
= note: this reference to an unsized type contains metadata, which makes it incompatible with a C pointer
189159

190160
error: `extern` fn uses type `PhantomData<bool>`, which is not FFI-safe
191-
--> $DIR/lint-fn.rs:177:43
161+
--> $DIR/lint-fn.rs:174:43
192162
|
193163
LL | pub extern "C" fn unused_generic2<T>() -> PhantomData<bool> {
194164
| ^^^^^^^^^^^^^^^^^ not FFI-safe
195165
|
196166
= note: composed only of `PhantomData`
197167

198168
error: `extern` fn uses type `Vec<T>`, which is not FFI-safe
199-
--> $DIR/lint-fn.rs:190:39
169+
--> $DIR/lint-fn.rs:187:39
200170
|
201171
LL | pub extern "C" fn used_generic4<T>(x: Vec<T>) { }
202172
| ^^^^^^ not FFI-safe
@@ -205,13 +175,13 @@ LL | pub extern "C" fn used_generic4<T>(x: Vec<T>) { }
205175
= note: `Vec<T>` has unspecified layout
206176

207177
error: `extern` fn uses type `Vec<T>`, which is not FFI-safe
208-
--> $DIR/lint-fn.rs:193:41
178+
--> $DIR/lint-fn.rs:190:41
209179
|
210180
LL | pub extern "C" fn used_generic5<T>() -> Vec<T> {
211181
| ^^^^^^ not FFI-safe
212182
|
213183
= help: consider adding a `#[repr(C)]` (not `#[repr(C,packed)]`) or `#[repr(transparent)]` attribute to `Vec<T>`
214184
= note: `Vec<T>` has unspecified layout
215185

216-
error: aborting due to 21 previous errors
186+
error: aborting due to 18 previous errors
217187

0 commit comments

Comments
 (0)
Please sign in to comment.