Skip to content

Commit b314654

Browse files
committed
Auto merge of #63991 - Centril:unique-improper-ctype, r=rkruppe
`improper_ctypes`: guard against accidental change to `Unique<T>` r? @eddyb
2 parents 2d851b3 + 960ecdc commit b314654

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/test/ui/lint/lint-ctypes-enum.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(transparent_enums, transparent_unions)]
2+
#![feature(ptr_internals)]
23
#![deny(improper_ctypes)]
34
#![allow(dead_code)]
45

@@ -44,6 +45,7 @@ extern {
4445
fn option_ref(x: Option<&'static u8>);
4546
fn option_fn(x: Option<extern "C" fn()>);
4647
fn nonnull(x: Option<std::ptr::NonNull<u8>>);
48+
fn unique(x: Option<std::ptr::Unique<u8>>); //~ ERROR enum has no representation hint
4749
fn nonzero_u8(x: Option<num::NonZeroU8>);
4850
fn nonzero_u16(x: Option<num::NonZeroU16>);
4951
fn nonzero_u32(x: Option<num::NonZeroU32>);
+21-13
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,90 @@
11
error: `extern` block uses type `U` which is not FFI-safe: enum has no representation hint
2-
--> $DIR/lint-ctypes-enum.rs:38:13
2+
--> $DIR/lint-ctypes-enum.rs:39:13
33
|
44
LL | fn uf(x: U);
55
| ^
66
|
77
note: lint level defined here
8-
--> $DIR/lint-ctypes-enum.rs:2:9
8+
--> $DIR/lint-ctypes-enum.rs:3:9
99
|
1010
LL | #![deny(improper_ctypes)]
1111
| ^^^^^^^^^^^^^^^
1212
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
1313
note: type defined here
14-
--> $DIR/lint-ctypes-enum.rs:8:1
14+
--> $DIR/lint-ctypes-enum.rs:9:1
1515
|
1616
LL | enum U { A }
1717
| ^^^^^^^^^^^^
1818

1919
error: `extern` block uses type `B` which is not FFI-safe: enum has no representation hint
20-
--> $DIR/lint-ctypes-enum.rs:39:13
20+
--> $DIR/lint-ctypes-enum.rs:40:13
2121
|
2222
LL | fn bf(x: B);
2323
| ^
2424
|
2525
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
2626
note: type defined here
27-
--> $DIR/lint-ctypes-enum.rs:9:1
27+
--> $DIR/lint-ctypes-enum.rs:10:1
2828
|
2929
LL | enum B { C, D }
3030
| ^^^^^^^^^^^^^^^
3131

3232
error: `extern` block uses type `T` which is not FFI-safe: enum has no representation hint
33-
--> $DIR/lint-ctypes-enum.rs:40:13
33+
--> $DIR/lint-ctypes-enum.rs:41:13
3434
|
3535
LL | fn tf(x: T);
3636
| ^
3737
|
3838
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
3939
note: type defined here
40-
--> $DIR/lint-ctypes-enum.rs:10:1
40+
--> $DIR/lint-ctypes-enum.rs:11:1
4141
|
4242
LL | enum T { E, F, G }
4343
| ^^^^^^^^^^^^^^^^^^
4444

45+
error: `extern` block uses type `std::option::Option<std::ptr::Unique<u8>>` which is not FFI-safe: enum has no representation hint
46+
--> $DIR/lint-ctypes-enum.rs:48:17
47+
|
48+
LL | fn unique(x: Option<std::ptr::Unique<u8>>);
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
|
51+
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
52+
4553
error: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
46-
--> $DIR/lint-ctypes-enum.rs:51:23
54+
--> $DIR/lint-ctypes-enum.rs:53:23
4755
|
4856
LL | fn nonzero_u128(x: Option<num::NonZeroU128>);
4957
| ^^^^^^^^^^^^^^^^^^^^^^^^
5058

5159
error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
52-
--> $DIR/lint-ctypes-enum.rs:58:23
60+
--> $DIR/lint-ctypes-enum.rs:60:23
5361
|
5462
LL | fn nonzero_i128(x: Option<num::NonZeroI128>);
5563
| ^^^^^^^^^^^^^^^^^^^^^^^^
5664

5765
error: `extern` block uses type `std::option::Option<TransparentUnion<std::num::NonZeroU8>>` which is not FFI-safe: enum has no representation hint
58-
--> $DIR/lint-ctypes-enum.rs:63:28
66+
--> $DIR/lint-ctypes-enum.rs:65:28
5967
|
6068
LL | fn transparent_union(x: Option<TransparentUnion<num::NonZeroU8>>);
6169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6270
|
6371
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
6472

6573
error: `extern` block uses type `std::option::Option<Rust<std::num::NonZeroU8>>` which is not FFI-safe: enum has no representation hint
66-
--> $DIR/lint-ctypes-enum.rs:65:20
74+
--> $DIR/lint-ctypes-enum.rs:67:20
6775
|
6876
LL | fn repr_rust(x: Option<Rust<num::NonZeroU8>>);
6977
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7078
|
7179
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
7280

7381
error: `extern` block uses type `std::result::Result<(), std::num::NonZeroI32>` which is not FFI-safe: enum has no representation hint
74-
--> $DIR/lint-ctypes-enum.rs:66:20
82+
--> $DIR/lint-ctypes-enum.rs:68:20
7583
|
7684
LL | fn no_result(x: Result<(), num::NonZeroI32>);
7785
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
7886
|
7987
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
8088

81-
error: aborting due to 8 previous errors
89+
error: aborting due to 9 previous errors
8290

0 commit comments

Comments
 (0)