]>
Commit | Line | Data |
---|---|---|
064997fb FG |
1 | #![deny(repr_transparent_external_private_fields)] |
2 | ||
3 | // aux-build: repr-transparent-non-exhaustive.rs | |
4 | extern crate repr_transparent_non_exhaustive; | |
5 | ||
6 | use repr_transparent_non_exhaustive::{ | |
7 | Private, | |
8 | NonExhaustive, | |
9 | NonExhaustiveEnum, | |
10 | NonExhaustiveVariant, | |
11 | ExternalIndirection, | |
12 | }; | |
13 | ||
14 | pub struct InternalPrivate { | |
15 | _priv: (), | |
16 | } | |
17 | ||
18 | #[non_exhaustive] | |
19 | pub struct InternalNonExhaustive; | |
20 | ||
21 | pub struct InternalIndirection<T> { | |
22 | x: T, | |
23 | } | |
24 | ||
25 | pub type Sized = i32; | |
26 | ||
27 | #[repr(transparent)] | |
28 | pub struct T1(Sized, InternalPrivate); | |
29 | #[repr(transparent)] | |
30 | pub struct T2(Sized, InternalNonExhaustive); | |
31 | #[repr(transparent)] | |
32 | pub struct T3(Sized, InternalIndirection<(InternalPrivate, InternalNonExhaustive)>); | |
33 | #[repr(transparent)] | |
34 | pub struct T4(Sized, ExternalIndirection<(InternalPrivate, InternalNonExhaustive)>); | |
35 | ||
36 | #[repr(transparent)] | |
37 | pub struct T5(Sized, Private); | |
2b03887a | 38 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
39 | //~| WARN this was previously accepted by the compiler |
40 | ||
41 | #[repr(transparent)] | |
42 | pub struct T6(Sized, NonExhaustive); | |
2b03887a | 43 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
44 | //~| WARN this was previously accepted by the compiler |
45 | ||
46 | #[repr(transparent)] | |
47 | pub struct T7(Sized, NonExhaustiveEnum); | |
2b03887a | 48 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
49 | //~| WARN this was previously accepted by the compiler |
50 | ||
51 | #[repr(transparent)] | |
52 | pub struct T8(Sized, NonExhaustiveVariant); | |
2b03887a | 53 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
54 | //~| WARN this was previously accepted by the compiler |
55 | ||
56 | #[repr(transparent)] | |
57 | pub struct T9(Sized, InternalIndirection<Private>); | |
2b03887a | 58 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
59 | //~| WARN this was previously accepted by the compiler |
60 | ||
61 | #[repr(transparent)] | |
62 | pub struct T10(Sized, InternalIndirection<NonExhaustive>); | |
2b03887a | 63 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
64 | //~| WARN this was previously accepted by the compiler |
65 | ||
66 | #[repr(transparent)] | |
67 | pub struct T11(Sized, InternalIndirection<NonExhaustiveEnum>); | |
2b03887a | 68 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
69 | //~| WARN this was previously accepted by the compiler |
70 | ||
71 | #[repr(transparent)] | |
72 | pub struct T12(Sized, InternalIndirection<NonExhaustiveVariant>); | |
2b03887a | 73 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
74 | //~| WARN this was previously accepted by the compiler |
75 | ||
76 | #[repr(transparent)] | |
77 | pub struct T13(Sized, ExternalIndirection<Private>); | |
2b03887a | 78 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
79 | //~| WARN this was previously accepted by the compiler |
80 | ||
81 | #[repr(transparent)] | |
82 | pub struct T14(Sized, ExternalIndirection<NonExhaustive>); | |
2b03887a | 83 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
84 | //~| WARN this was previously accepted by the compiler |
85 | ||
86 | #[repr(transparent)] | |
87 | pub struct T15(Sized, ExternalIndirection<NonExhaustiveEnum>); | |
2b03887a | 88 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
89 | //~| WARN this was previously accepted by the compiler |
90 | ||
91 | #[repr(transparent)] | |
92 | pub struct T16(Sized, ExternalIndirection<NonExhaustiveVariant>); | |
2b03887a | 93 | //~^ ERROR zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types |
064997fb FG |
94 | //~| WARN this was previously accepted by the compiler |
95 | ||
96 | fn main() {} |