Skip to content

Commit 35e3b4d

Browse files
committed
tests for #[repr(no_niche)].
1 parent 88747ff commit 35e3b4d

5 files changed

+417
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::num::NonZeroU8 as N8;
2+
use std::num::NonZeroU16 as N16;
3+
4+
#[repr(no_niche)]
5+
pub struct Cloaked(N16);
6+
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]
7+
8+
#[repr(transparent, no_niche)]
9+
pub struct Shadowy(N16);
10+
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]
11+
12+
#[repr(no_niche)]
13+
pub enum Cloaked1 { _A(N16), }
14+
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]
15+
16+
#[repr(no_niche)]
17+
pub enum Cloaked2 { _A(N16), _B(u8, N8) }
18+
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]
19+
20+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error[E0658]: the attribute `repr(no_niche)` is currently unstable
2+
--> $DIR/feature-gate-no-niche.rs:4:8
3+
|
4+
LL | #[repr(no_niche)]
5+
| ^^^^^^^^
6+
|
7+
= help: add `#![feature(no_niche)]` to the crate attributes to enable
8+
9+
error[E0658]: the attribute `repr(no_niche)` is currently unstable
10+
--> $DIR/feature-gate-no-niche.rs:8:21
11+
|
12+
LL | #[repr(transparent, no_niche)]
13+
| ^^^^^^^^
14+
|
15+
= help: add `#![feature(no_niche)]` to the crate attributes to enable
16+
17+
error[E0658]: the attribute `repr(no_niche)` is currently unstable
18+
--> $DIR/feature-gate-no-niche.rs:12:8
19+
|
20+
LL | #[repr(no_niche)]
21+
| ^^^^^^^^
22+
|
23+
= help: add `#![feature(no_niche)]` to the crate attributes to enable
24+
25+
error[E0658]: the attribute `repr(no_niche)` is currently unstable
26+
--> $DIR/feature-gate-no-niche.rs:16:8
27+
|
28+
LL | #[repr(no_niche)]
29+
| ^^^^^^^^
30+
|
31+
= help: add `#![feature(no_niche)]` to the crate attributes to enable
32+
33+
error: aborting due to 4 previous errors
34+
35+
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(no_niche)]
2+
3+
use std::num::NonZeroU8 as N8;
4+
use std::num::NonZeroU16 as N16;
5+
6+
#[repr(no_niche)]
7+
pub union Cloaked1 { _A: N16 }
8+
//~^^ ERROR attribute should be applied to struct or enum [E0517]
9+
10+
#[repr(no_niche)]
11+
pub union Cloaked2 { _A: N16, _B: (u8, N8) }
12+
//~^^ ERROR attribute should be applied to struct or enum [E0517]
13+
14+
fn main() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0517]: attribute should be applied to struct or enum
2+
--> $DIR/repr-no-niche-inapplicable-to-unions.rs:6:8
3+
|
4+
LL | #[repr(no_niche)]
5+
| ^^^^^^^^
6+
LL | pub union Cloaked1 { _A: N16 }
7+
| ------------------------------ not a struct or enum
8+
9+
error[E0517]: attribute should be applied to struct or enum
10+
--> $DIR/repr-no-niche-inapplicable-to-unions.rs:10:8
11+
|
12+
LL | #[repr(no_niche)]
13+
| ^^^^^^^^
14+
LL | pub union Cloaked2 { _A: N16, _B: (u8, N8) }
15+
| -------------------------------------------- not a struct or enum
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0517`.

0 commit comments

Comments
 (0)