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 5fb6784

Browse files
committedJul 10, 2022
add more tests
1 parent fc26ca1 commit 5fb6784

File tree

3 files changed

+122
-18
lines changed

3 files changed

+122
-18
lines changed
 

‎src/test/ui/repr/auxiliary/repr-transparent-non-exhaustive.rs

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ pub struct Private { _priv: () }
55
#[non_exhaustive]
66
pub struct NonExhaustive {}
77

8+
#[non_exhaustive]
9+
pub enum NonExhaustiveEnum {}
10+
11+
pub enum NonExhaustiveVariant {
12+
#[non_exhaustive]
13+
A,
14+
}
15+
816
pub struct ExternalIndirection<T> {
917
pub x: T,
1018
}

‎src/test/ui/repr/repr-transparent-non-exhaustive.rs

+41-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
// aux-build: repr-transparent-non-exhaustive.rs
44
extern crate repr_transparent_non_exhaustive;
55

6-
use repr_transparent_non_exhaustive::{Private, NonExhaustive, ExternalIndirection};
6+
use repr_transparent_non_exhaustive::{
7+
Private,
8+
NonExhaustive,
9+
NonExhaustiveEnum,
10+
NonExhaustiveVariant,
11+
ExternalIndirection,
12+
};
713

814
pub struct InternalPrivate {
915
_priv: (),
@@ -38,22 +44,52 @@ pub struct T6(Sized, NonExhaustive);
3844
//~| WARN this was previously accepted by the compiler
3945

4046
#[repr(transparent)]
41-
pub struct T7(Sized, InternalIndirection<Private>);
47+
pub struct T7(Sized, NonExhaustiveEnum);
4248
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
4349
//~| WARN this was previously accepted by the compiler
4450

4551
#[repr(transparent)]
46-
pub struct T8(Sized, InternalIndirection<NonExhaustive>);
52+
pub struct T8(Sized, NonExhaustiveVariant);
4753
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
4854
//~| WARN this was previously accepted by the compiler
4955

5056
#[repr(transparent)]
51-
pub struct T9(Sized, ExternalIndirection<Private>);
57+
pub struct T9(Sized, InternalIndirection<Private>);
5258
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
5359
//~| WARN this was previously accepted by the compiler
5460

5561
#[repr(transparent)]
56-
pub struct T10(Sized, ExternalIndirection<NonExhaustive>);
62+
pub struct T10(Sized, InternalIndirection<NonExhaustive>);
63+
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
64+
//~| WARN this was previously accepted by the compiler
65+
66+
#[repr(transparent)]
67+
pub struct T11(Sized, InternalIndirection<NonExhaustiveEnum>);
68+
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
69+
//~| WARN this was previously accepted by the compiler
70+
71+
#[repr(transparent)]
72+
pub struct T12(Sized, InternalIndirection<NonExhaustiveVariant>);
73+
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
74+
//~| WARN this was previously accepted by the compiler
75+
76+
#[repr(transparent)]
77+
pub struct T13(Sized, ExternalIndirection<Private>);
78+
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
79+
//~| WARN this was previously accepted by the compiler
80+
81+
#[repr(transparent)]
82+
pub struct T14(Sized, ExternalIndirection<NonExhaustive>);
83+
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
84+
//~| WARN this was previously accepted by the compiler
85+
86+
#[repr(transparent)]
87+
pub struct T15(Sized, ExternalIndirection<NonExhaustiveEnum>);
88+
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
89+
//~| WARN this was previously accepted by the compiler
90+
91+
#[repr(transparent)]
92+
pub struct T16(Sized, ExternalIndirection<NonExhaustiveVariant>);
5793
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
5894
//~| WARN this was previously accepted by the compiler
5995

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
2-
--> $DIR/repr-transparent-non-exhaustive.rs:31:22
2+
--> $DIR/repr-transparent-non-exhaustive.rs:37:22
33
|
44
LL | pub struct T5(Sized, Private);
55
| ^^^^^^^
@@ -14,7 +14,7 @@ LL | #![deny(repr_transparent_external_private_fields)]
1414
= note: this struct contains `Private`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
1515

1616
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
17-
--> $DIR/repr-transparent-non-exhaustive.rs:36:22
17+
--> $DIR/repr-transparent-non-exhaustive.rs:42:22
1818
|
1919
LL | pub struct T6(Sized, NonExhaustive);
2020
| ^^^^^^^^^^^^^
@@ -24,44 +24,104 @@ LL | pub struct T6(Sized, NonExhaustive);
2424
= note: this struct contains `NonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
2525

2626
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
27-
--> $DIR/repr-transparent-non-exhaustive.rs:41:22
27+
--> $DIR/repr-transparent-non-exhaustive.rs:47:22
2828
|
29-
LL | pub struct T7(Sized, InternalIndirection<Private>);
29+
LL | pub struct T7(Sized, NonExhaustiveEnum);
30+
| ^^^^^^^^^^^^^^^^^
31+
|
32+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
33+
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
34+
= note: this enum contains `NonExhaustiveEnum`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
35+
36+
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
37+
--> $DIR/repr-transparent-non-exhaustive.rs:52:22
38+
|
39+
LL | pub struct T8(Sized, NonExhaustiveVariant);
40+
| ^^^^^^^^^^^^^^^^^^^^
41+
|
42+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
43+
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
44+
= note: this enum contains `NonExhaustiveVariant`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
45+
46+
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
47+
--> $DIR/repr-transparent-non-exhaustive.rs:57:22
48+
|
49+
LL | pub struct T9(Sized, InternalIndirection<Private>);
3050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3151
|
3252
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3353
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
3454
= note: this struct contains `Private`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
3555

3656
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
37-
--> $DIR/repr-transparent-non-exhaustive.rs:46:22
57+
--> $DIR/repr-transparent-non-exhaustive.rs:62:23
3858
|
39-
LL | pub struct T8(Sized, InternalIndirection<NonExhaustive>);
40-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59+
LL | pub struct T10(Sized, InternalIndirection<NonExhaustive>);
60+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4161
|
4262
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4363
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
4464
= note: this struct contains `NonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
4565

4666
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
47-
--> $DIR/repr-transparent-non-exhaustive.rs:51:22
67+
--> $DIR/repr-transparent-non-exhaustive.rs:67:23
4868
|
49-
LL | pub struct T9(Sized, ExternalIndirection<Private>);
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69+
LL | pub struct T11(Sized, InternalIndirection<NonExhaustiveEnum>);
70+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71+
|
72+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
73+
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
74+
= note: this enum contains `NonExhaustiveEnum`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
75+
76+
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
77+
--> $DIR/repr-transparent-non-exhaustive.rs:72:23
78+
|
79+
LL | pub struct T12(Sized, InternalIndirection<NonExhaustiveVariant>);
80+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
81+
|
82+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
83+
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
84+
= note: this enum contains `NonExhaustiveVariant`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
85+
86+
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
87+
--> $DIR/repr-transparent-non-exhaustive.rs:77:23
88+
|
89+
LL | pub struct T13(Sized, ExternalIndirection<Private>);
90+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5191
|
5292
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5393
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
5494
= note: this struct contains `Private`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
5595

5696
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
57-
--> $DIR/repr-transparent-non-exhaustive.rs:56:23
97+
--> $DIR/repr-transparent-non-exhaustive.rs:82:23
5898
|
59-
LL | pub struct T10(Sized, ExternalIndirection<NonExhaustive>);
99+
LL | pub struct T14(Sized, ExternalIndirection<NonExhaustive>);
60100
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61101
|
62102
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
63103
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
64104
= note: this struct contains `NonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
65105

66-
error: aborting due to 6 previous errors
106+
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
107+
--> $DIR/repr-transparent-non-exhaustive.rs:87:23
108+
|
109+
LL | pub struct T15(Sized, ExternalIndirection<NonExhaustiveEnum>);
110+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111+
|
112+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
113+
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
114+
= note: this enum contains `NonExhaustiveEnum`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
115+
116+
error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
117+
--> $DIR/repr-transparent-non-exhaustive.rs:92:23
118+
|
119+
LL | pub struct T16(Sized, ExternalIndirection<NonExhaustiveVariant>);
120+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121+
|
122+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
123+
= note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
124+
= note: this enum contains `NonExhaustiveVariant`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
125+
126+
error: aborting due to 12 previous errors
67127

0 commit comments

Comments
 (0)
Please sign in to comment.