Skip to content

Commit

Permalink
Add test with attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 25, 2021
1 parent e0ae980 commit 3e3dff7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/ui/exhaustive_items.fixed
Expand Up @@ -16,6 +16,16 @@ pub mod enums {
Quux(String),
}

/// Some docs
#[repr(C)]
#[non_exhaustive]
pub enum ExhaustiveWithAttrs {
Foo,
Bar,
Baz,
Quux(String),
}

// no warning, already non_exhaustive
#[non_exhaustive]
pub enum NonExhaustive {
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/exhaustive_items.rs
Expand Up @@ -15,6 +15,15 @@ pub mod enums {
Quux(String),
}

/// Some docs
#[repr(C)]
pub enum ExhaustiveWithAttrs {
Foo,
Bar,
Baz,
Quux(String),
}

// no warning, already non_exhaustive
#[non_exhaustive]
pub enum NonExhaustive {
Expand Down
21 changes: 19 additions & 2 deletions tests/ui/exhaustive_items.stderr
Expand Up @@ -20,8 +20,25 @@ LL | #[non_exhaustive]
LL | pub enum Exhaustive {
|

error: exported enums should not be exhaustive
--> $DIR/exhaustive_items.rs:20:5
|
LL | / pub enum ExhaustiveWithAttrs {
LL | | Foo,
LL | | Bar,
LL | | Baz,
LL | | Quux(String),
LL | | }
| |_____^
|
help: try adding #[non_exhaustive]
|
LL | #[non_exhaustive]
LL | pub enum ExhaustiveWithAttrs {
|

error: exported structs should not be exhaustive
--> $DIR/exhaustive_items.rs:46:5
--> $DIR/exhaustive_items.rs:55:5
|
LL | / pub struct Exhaustive {
LL | | foo: u8,
Expand All @@ -40,5 +57,5 @@ LL | #[non_exhaustive]
LL | pub struct Exhaustive {
|

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

0 comments on commit 3e3dff7

Please sign in to comment.