Skip to content

Commit 3e3dff7

Browse files
committed
Add test with attrs
1 parent e0ae980 commit 3e3dff7

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

tests/ui/exhaustive_items.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ pub mod enums {
1616
Quux(String),
1717
}
1818

19+
/// Some docs
20+
#[repr(C)]
21+
#[non_exhaustive]
22+
pub enum ExhaustiveWithAttrs {
23+
Foo,
24+
Bar,
25+
Baz,
26+
Quux(String),
27+
}
28+
1929
// no warning, already non_exhaustive
2030
#[non_exhaustive]
2131
pub enum NonExhaustive {

tests/ui/exhaustive_items.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ pub mod enums {
1515
Quux(String),
1616
}
1717

18+
/// Some docs
19+
#[repr(C)]
20+
pub enum ExhaustiveWithAttrs {
21+
Foo,
22+
Bar,
23+
Baz,
24+
Quux(String),
25+
}
26+
1827
// no warning, already non_exhaustive
1928
#[non_exhaustive]
2029
pub enum NonExhaustive {

tests/ui/exhaustive_items.stderr

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,25 @@ LL | #[non_exhaustive]
2020
LL | pub enum Exhaustive {
2121
|
2222

23+
error: exported enums should not be exhaustive
24+
--> $DIR/exhaustive_items.rs:20:5
25+
|
26+
LL | / pub enum ExhaustiveWithAttrs {
27+
LL | | Foo,
28+
LL | | Bar,
29+
LL | | Baz,
30+
LL | | Quux(String),
31+
LL | | }
32+
| |_____^
33+
|
34+
help: try adding #[non_exhaustive]
35+
|
36+
LL | #[non_exhaustive]
37+
LL | pub enum ExhaustiveWithAttrs {
38+
|
39+
2340
error: exported structs should not be exhaustive
24-
--> $DIR/exhaustive_items.rs:46:5
41+
--> $DIR/exhaustive_items.rs:55:5
2542
|
2643
LL | / pub struct Exhaustive {
2744
LL | | foo: u8,
@@ -40,5 +57,5 @@ LL | #[non_exhaustive]
4057
LL | pub struct Exhaustive {
4158
|
4259

43-
error: aborting due to 2 previous errors
60+
error: aborting due to 3 previous errors
4461

0 commit comments

Comments
 (0)