Skip to content

Commit 6c19cff

Browse files
committed
chore: make tidy happy
1 parent 9cf56ff commit 6c19cff

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

compiler/rustc_lint/messages.ftl

+3-3
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,13 @@ lint_improper_ctypes_ptr_validity_reason =
406406
lint_improper_ctypes_sized_ptr_to_unsafe_type =
407407
this reference (`{$ty}`) is ABI-compatible with a C pointer, but `{$inner_ty}` itself does not have a C layout
408408
409-
lint_improper_ctypes_struct_dueto = this struct/enum/union (`{$ty}`) is FFI-unsafe due to a `{$inner_ty}` field
410409
lint_improper_ctypes_slice_help = consider using a raw pointer to the slice's first element (and a length) instead
411-
412410
lint_improper_ctypes_slice_reason = slices have no C equivalent
413-
lint_improper_ctypes_str_help = consider using `*const u8` and a length instead
414411
412+
lint_improper_ctypes_str_help = consider using `*const u8` and a length instead
415413
lint_improper_ctypes_str_reason = string slices have no C equivalent
414+
415+
lint_improper_ctypes_struct_dueto = this struct/enum/union (`{$ty}`) is FFI-unsafe due to a `{$inner_ty}` field
416416
lint_improper_ctypes_struct_fieldless_help = consider adding a member to this struct
417417
418418
lint_improper_ctypes_struct_fieldless_reason = this struct has no fields

compiler/rustc_lint/src/types/improper_ctypes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl CTypesVisitorState {
407407
fn value_may_be_unchecked(self) -> bool {
408408
// function declarations are assumed to be rust-caller, non-rust-callee
409409
// function definitions are assumed to be maybe-not-rust-caller, rust-callee
410-
// FnPtrs are... well, nothing's certain about anything. (TODO need more flags in enum?)
410+
// FnPtrs are... well, nothing's certain about anything. (FIXME need more flags in enum?)
411411
// Same with statics.
412412
if self.is_in_static() {
413413
true
@@ -768,7 +768,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
768768

769769
if def.variants().is_empty() {
770770
// Empty enums are implicitely handled as the never type:
771-
// TODO think about the FFI-safety of functions that use that
771+
// FIXME think about the FFI-safety of functions that use that
772772
return FfiSafe;
773773
}
774774
// Check for a repr() attribute to specify the size of the
@@ -818,7 +818,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
818818
.iter()
819819
.map(|variant| {
820820
self.visit_variant_fields(state, ty, def, variant, args)
821-
// TODO: check that enums allow any (up to all) variants to be phantoms?
821+
// FIXME: check that enums allow any (up to all) variants to be phantoms?
822822
// (previous code says no, but I don't know why? the problem with phantoms is that they're ZSTs, right?)
823823
.forbid_phantom()
824824
})
@@ -1169,7 +1169,7 @@ impl<'c, 'tcx> ImproperCTypesLint<'c, 'tcx> {
11691169
(span, ffi_res)
11701170
})
11711171
// even in function *definitions*, `FnPtr`s are always function declarations ...right?
1172-
// (TODO: we can't do that yet because one of rustc's crates can't compile if we do)
1172+
// (FIXME: we can't do that yet because one of rustc's crates can't compile if we do)
11731173
.for_each(|(span, ffi_res)| self.process_ffi_result(span, ffi_res, fn_mode));
11741174
//.drain();
11751175
}

tests/ui/lint/lint-ctypes.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ extern "C" {
9494
pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `&str`
9595
pub fn transparent_fn(p: TransparentBoxFn);
9696
pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]`
97-
pub fn multi_errors_per_arg(f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>));
98-
//~^ ERROR: uses type `char`
99-
//~^^ ERROR: uses type `&dyn Debug`
97+
pub fn multi_errors_per_arg(
98+
f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>)
99+
);
100+
//~^^ ERROR: uses type `char`
101+
//~^^^ ERROR: uses type `&dyn Debug`
100102
// (possible FIXME: the in-struct `char` field doesn't get a warning due ^^)
101-
//~^^^^ ERROR: uses type `&[u8]`
103+
//~^^^^^ ERROR: uses type `&[u8]`
102104

103105
pub fn struct_unsized_ptr_no_metadata(p: &UnsizedStructBecauseForeign);
104106
pub fn struct_unsized_ptr_has_metadata(p: &UnsizedStructBecauseDyn); //~ ERROR uses type `&UnsizedStructBecauseDyn`

tests/ui/lint/lint-ctypes.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -201,29 +201,29 @@ LL | pub fn raw_array(arr: [u8; 8]);
201201
= note: passing raw arrays by value is not FFI-safe
202202

203203
error: `extern` block uses type `char`, which is not FFI-safe
204-
--> $DIR/lint-ctypes.rs:97:36
204+
--> $DIR/lint-ctypes.rs:98:12
205205
|
206-
LL | pub fn multi_errors_per_arg(f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>));
207-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
206+
LL | f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>)
207+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
208208
|
209209
= note: the function pointer to `for<'a, 'b> extern "C" fn(char, &'a (dyn Debug + 'a), Box<TwoBadTypes<'b>>)` is FFI-unsafe due to `char`
210210
= help: consider using `u32` or `libc::wchar_t` instead
211211
= note: the `char` type has no C equivalent
212212

213213
error: `extern` block uses type `&dyn Debug`, which is not FFI-safe
214-
--> $DIR/lint-ctypes.rs:97:36
214+
--> $DIR/lint-ctypes.rs:98:12
215215
|
216-
LL | pub fn multi_errors_per_arg(f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>));
217-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
216+
LL | f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>)
217+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
218218
|
219219
= note: the function pointer to `for<'a, 'b> extern "C" fn(char, &'a (dyn Debug + 'a), Box<TwoBadTypes<'b>>)` is FFI-unsafe due to `&dyn Debug`
220220
= note: this reference to an unsized type contains metadata, which makes it incompatible with a C pointer
221221

222222
error: `extern` block uses type `&[u8]`, which is not FFI-safe
223-
--> $DIR/lint-ctypes.rs:97:36
223+
--> $DIR/lint-ctypes.rs:98:12
224224
|
225-
LL | pub fn multi_errors_per_arg(f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>));
226-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
225+
LL | f: for<'a> extern "C" fn(a:char, b:&dyn Debug, c: Box<TwoBadTypes<'a>>)
226+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
227227
|
228228
= note: the function pointer to `for<'a, 'b> extern "C" fn(char, &'a (dyn Debug + 'a), Box<TwoBadTypes<'b>>)` is FFI-unsafe due to `Box<TwoBadTypes<'_>>`
229229
= note: this reference (`Box<TwoBadTypes<'_>>`) is ABI-compatible with a C pointer, but `TwoBadTypes<'_>` itself does not have a C layout
@@ -237,15 +237,15 @@ LL | pub struct TwoBadTypes<'a> {
237237
= note: this reference to an unsized type contains metadata, which makes it incompatible with a C pointer
238238

239239
error: `extern` block uses type `&UnsizedStructBecauseDyn`, which is not FFI-safe
240-
--> $DIR/lint-ctypes.rs:104:47
240+
--> $DIR/lint-ctypes.rs:106:47
241241
|
242242
LL | pub fn struct_unsized_ptr_has_metadata(p: &UnsizedStructBecauseDyn);
243243
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
244244
|
245245
= note: this reference to an unsized type contains metadata, which makes it incompatible with a C pointer
246246

247247
error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe
248-
--> $DIR/lint-ctypes.rs:106:26
248+
--> $DIR/lint-ctypes.rs:108:26
249249
|
250250
LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>);
251251
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -254,7 +254,7 @@ LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>);
254254
= note: enum has no representation hint
255255

256256
error: `extern` block uses type `Option<UnsafeCell<&i32>>`, which is not FFI-safe
257-
--> $DIR/lint-ctypes.rs:108:26
257+
--> $DIR/lint-ctypes.rs:110:26
258258
|
259259
LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
260260
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -263,15 +263,15 @@ LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
263263
= note: enum has no representation hint
264264

265265
error: `extern` block uses type `u128`, which is not FFI-safe
266-
--> $DIR/lint-ctypes.rs:111:34
266+
--> $DIR/lint-ctypes.rs:113:34
267267
|
268268
LL | pub static static_u128_type: u128;
269269
| ^^^^ not FFI-safe
270270
|
271271
= note: 128-bit integers don't currently have a known stable ABI
272272

273273
error: `extern` block uses type `u128`, which is not FFI-safe
274-
--> $DIR/lint-ctypes.rs:112:40
274+
--> $DIR/lint-ctypes.rs:114:40
275275
|
276276
LL | pub static static_u128_array_type: [u128; 16];
277277
| ^^^^^^^^^^ not FFI-safe

0 commit comments

Comments
 (0)