Skip to content

Commit

Permalink
tests for #[repr(no_niche)].
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Feb 10, 2020
1 parent 88747ff commit 35e3b4d
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/ui/repr/feature-gate-no-niche.rs
@@ -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
@@ -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
@@ -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
@@ -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`.

0 comments on commit 35e3b4d

Please sign in to comment.