Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests for #[repr(no_niche)].
  • Loading branch information
pnkfelix committed Feb 10, 2020
commit 35e3b4d1d879851610cff152f0996a895da7cae1
20 changes: 20 additions & 0 deletions src/test/ui/repr/feature-gate-no-niche.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::num::NonZeroU8 as N8;
use std::num::NonZeroU16 as N16;

#[repr(no_niche)]
pub struct Cloaked(N16);
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]

#[repr(transparent, no_niche)]
pub struct Shadowy(N16);
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]

#[repr(no_niche)]
pub enum Cloaked1 { _A(N16), }
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]

#[repr(no_niche)]
pub enum Cloaked2 { _A(N16), _B(u8, N8) }
//~^^ ERROR the attribute `repr(no_niche)` is currently unstable [E0658]

fn main() { }
35 changes: 35 additions & 0 deletions src/test/ui/repr/feature-gate-no-niche.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error[E0658]: the attribute `repr(no_niche)` is currently unstable
--> $DIR/feature-gate-no-niche.rs:4:8
|
LL | #[repr(no_niche)]
| ^^^^^^^^
|
= help: add `#![feature(no_niche)]` to the crate attributes to enable

error[E0658]: the attribute `repr(no_niche)` is currently unstable
--> $DIR/feature-gate-no-niche.rs:8:21
|
LL | #[repr(transparent, no_niche)]
| ^^^^^^^^
|
= help: add `#![feature(no_niche)]` to the crate attributes to enable

error[E0658]: the attribute `repr(no_niche)` is currently unstable
--> $DIR/feature-gate-no-niche.rs:12:8
|
LL | #[repr(no_niche)]
| ^^^^^^^^
|
= help: add `#![feature(no_niche)]` to the crate attributes to enable

error[E0658]: the attribute `repr(no_niche)` is currently unstable
--> $DIR/feature-gate-no-niche.rs:16:8
|
LL | #[repr(no_niche)]
| ^^^^^^^^
|
= help: add `#![feature(no_niche)]` to the crate attributes to enable

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0658`.
14 changes: 14 additions & 0 deletions src/test/ui/repr/repr-no-niche-inapplicable-to-unions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![feature(no_niche)]

use std::num::NonZeroU8 as N8;
use std::num::NonZeroU16 as N16;

#[repr(no_niche)]
pub union Cloaked1 { _A: N16 }
//~^^ ERROR attribute should be applied to struct or enum [E0517]

#[repr(no_niche)]
pub union Cloaked2 { _A: N16, _B: (u8, N8) }
//~^^ ERROR attribute should be applied to struct or enum [E0517]

fn main() { }
19 changes: 19 additions & 0 deletions src/test/ui/repr/repr-no-niche-inapplicable-to-unions.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0517]: attribute should be applied to struct or enum
--> $DIR/repr-no-niche-inapplicable-to-unions.rs:6:8
|
LL | #[repr(no_niche)]
| ^^^^^^^^
LL | pub union Cloaked1 { _A: N16 }
| ------------------------------ not a struct or enum

error[E0517]: attribute should be applied to struct or enum
--> $DIR/repr-no-niche-inapplicable-to-unions.rs:10:8
|
LL | #[repr(no_niche)]
| ^^^^^^^^
LL | pub union Cloaked2 { _A: N16, _B: (u8, N8) }
| -------------------------------------------- not a struct or enum

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0517`.
Loading