Skip to content

Commit e4cc9b3

Browse files
committed
Add test
1 parent 6dec76f commit e4cc9b3

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

tests/ui/uninhabited/auxiliary/staged-api.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ pub struct Foo<T> {
66
#[unstable(feature = "unstable", issue = "none")]
77
pub field: T,
88
}
9+
10+
#[unstable(feature = "my_coro_state", issue = "none")]
11+
pub enum MyCoroutineState<Y, R> {
12+
Yielded(Y),
13+
Complete(R),
14+
}

tests/ui/uninhabited/uninhabited-unstable-field.current.stderr

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: type `Foo<Void>` is non-empty
2-
--> $DIR/uninhabited-unstable-field.rs:13:11
2+
--> $DIR/uninhabited-unstable-field.rs:15:11
33
|
44
LL | match x {}
55
| ^
@@ -17,6 +17,27 @@ LL + _ => todo!(),
1717
LL ~ }
1818
|
1919

20-
error: aborting due to 1 previous error
20+
error[E0004]: non-exhaustive patterns: `MyCoroutineState::Complete(_)` not covered
21+
--> $DIR/uninhabited-unstable-field.rs:34:11
22+
|
23+
LL | match x {
24+
| ^ pattern `MyCoroutineState::Complete(_)` not covered
25+
|
26+
note: `MyCoroutineState<i32, !>` defined here
27+
--> $DIR/auxiliary/staged-api.rs:11:1
28+
|
29+
LL | pub enum MyCoroutineState<Y, R> {
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
LL | Yielded(Y),
32+
LL | Complete(R),
33+
| -------- not covered
34+
= note: the matched value is of type `MyCoroutineState<i32, !>`
35+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
36+
|
37+
LL ~ MyCoroutineState::Yielded(_) => {},
38+
LL + MyCoroutineState::Complete(_) => todo!()
39+
|
40+
41+
error: aborting due to 2 previous errors
2142

2243
For more information about this error, try `rustc --explain E0004`.

tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: type `Foo<Void>` is non-empty
2-
--> $DIR/uninhabited-unstable-field.rs:13:11
2+
--> $DIR/uninhabited-unstable-field.rs:15:11
33
|
44
LL | match x {}
55
| ^
@@ -17,6 +17,27 @@ LL + _ => todo!(),
1717
LL ~ }
1818
|
1919

20-
error: aborting due to 1 previous error
20+
error[E0004]: non-exhaustive patterns: `MyCoroutineState::Complete(_)` not covered
21+
--> $DIR/uninhabited-unstable-field.rs:34:11
22+
|
23+
LL | match x {
24+
| ^ pattern `MyCoroutineState::Complete(_)` not covered
25+
|
26+
note: `MyCoroutineState<i32, !>` defined here
27+
--> $DIR/auxiliary/staged-api.rs:11:1
28+
|
29+
LL | pub enum MyCoroutineState<Y, R> {
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
LL | Yielded(Y),
32+
LL | Complete(R),
33+
| -------- not covered
34+
= note: the matched value is of type `MyCoroutineState<i32, !>`
35+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
36+
|
37+
LL ~ MyCoroutineState::Yielded(_) => {},
38+
LL + MyCoroutineState::Complete(_) => todo!()
39+
|
40+
41+
error: aborting due to 2 previous errors
2142

2243
For more information about this error, try `rustc --explain E0004`.

tests/ui/uninhabited/uninhabited-unstable-field.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
//@ aux-build: staged-api.rs
22
//@ revisions: current exhaustive
3-
4-
#![feature(exhaustive_patterns)]
3+
#![cfg_attr(exhaustive, feature(exhaustive_patterns))]
4+
#![feature(never_type)]
5+
#![feature(my_coro_state)] // Custom feature from `staged-api.rs`
6+
#![deny(unreachable_patterns)]
57

68
extern crate staged_api;
79

8-
use staged_api::Foo;
10+
use staged_api::{Foo, MyCoroutineState};
911

1012
enum Void {}
1113

@@ -23,7 +25,20 @@ fn demo2(x: Foo<Void>) {
2325

2426
// Same as above, but for wildcard.
2527
fn demo3(x: Foo<Void>) {
26-
match x { _ => {} }
28+
match x {
29+
_ => {}
30+
}
31+
}
32+
33+
fn unstable_enum(x: MyCoroutineState<i32, !>) {
34+
match x {
35+
//~^ ERROR non-exhaustive patterns
36+
MyCoroutineState::Yielded(_) => {}
37+
}
38+
match x {
39+
MyCoroutineState::Yielded(_) => {}
40+
MyCoroutineState::Complete(_) => {}
41+
}
2742
}
2843

2944
fn main() {}

0 commit comments

Comments
 (0)