Skip to content

Commit ffdd4b9

Browse files
committed
Add tests for >1-aligned ZSTs + extern type in a transparent struct
1 parent 1bf0340 commit ffdd4b9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/test/ui/repr/repr-transparent.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// - repr-transparent-other-reprs.rs
1414
// - repr-transparent-other-items.rs
1515

16-
#![feature(repr_align)]
16+
#![feature(extern_types, repr_align)]
1717

1818
use std::marker::PhantomData;
1919

@@ -49,4 +49,14 @@ struct ZstAlign32<T>(PhantomData<T>);
4949
#[repr(transparent)]
5050
struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR alignment larger than 1
5151

52+
extern "C" {
53+
type ExternType;
54+
}
55+
56+
#[repr(transparent)]
57+
struct NontrivialAlignZstExtern([u16; 0], ExternType); //~ ERROR alignment larger than 1
58+
59+
#[repr(transparent)]
60+
struct GenericAlignExtern<T>(ZstAlign32<T>, ExternType); //~ ERROR alignment larger than 1
61+
5262
fn main() {}

src/test/ui/repr/repr-transparent.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,19 @@ error[E0691]: zero-sized field in transparent struct has alignment larger than 1
6666
LL | struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR alignment larger than 1
6767
| ^^^^^^^^^^^^^
6868

69-
error: aborting due to 8 previous errors
69+
error[E0691]: zero-sized field in transparent struct has alignment larger than 1
70+
--> $DIR/repr-transparent.rs:57:33
71+
|
72+
LL | struct NontrivialAlignZstExtern([u16; 0], ExternType); //~ ERROR alignment larger than 1
73+
| ^^^^^^^^
74+
75+
error[E0691]: zero-sized field in transparent struct has alignment larger than 1
76+
--> $DIR/repr-transparent.rs:60:30
77+
|
78+
LL | struct GenericAlignExtern<T>(ZstAlign32<T>, ExternType); //~ ERROR alignment larger than 1
79+
| ^^^^^^^^^^^^^
80+
81+
error: aborting due to 10 previous errors
7082

7183
Some errors occurred: E0690, E0691.
7284
For more information about an error, try `rustc --explain E0690`.

0 commit comments

Comments
 (0)