This commit is contained in:
Nadrieril 2025-07-20 14:41:27 +02:00
parent 81af9d4569
commit e9fb744207
4 changed files with 71 additions and 8 deletions

View file

@ -6,3 +6,9 @@ pub struct Foo<T> {
#[unstable(feature = "unstable", issue = "none")]
pub field: T,
}
#[unstable(feature = "my_coro_state", issue = "none")]
pub enum MyCoroutineState<Y, R> {
Yielded(Y),
Complete(R),
}

View file

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `Foo<Void>` is non-empty
--> $DIR/uninhabited-unstable-field.rs:13:11
--> $DIR/uninhabited-unstable-field.rs:15:11
|
LL | match x {}
| ^
@ -17,6 +17,27 @@ LL + _ => todo!(),
LL ~ }
|
error: aborting due to 1 previous error
error[E0004]: non-exhaustive patterns: `MyCoroutineState::Complete(_)` not covered
--> $DIR/uninhabited-unstable-field.rs:34:11
|
LL | match x {
| ^ pattern `MyCoroutineState::Complete(_)` not covered
|
note: `MyCoroutineState<i32, !>` defined here
--> $DIR/auxiliary/staged-api.rs:11:1
|
LL | pub enum MyCoroutineState<Y, R> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Yielded(Y),
LL | Complete(R),
| -------- not covered
= note: the matched value is of type `MyCoroutineState<i32, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ MyCoroutineState::Yielded(_) => {},
LL + MyCoroutineState::Complete(_) => todo!()
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0004`.

View file

@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `Foo<Void>` is non-empty
--> $DIR/uninhabited-unstable-field.rs:13:11
--> $DIR/uninhabited-unstable-field.rs:15:11
|
LL | match x {}
| ^
@ -17,6 +17,27 @@ LL + _ => todo!(),
LL ~ }
|
error: aborting due to 1 previous error
error[E0004]: non-exhaustive patterns: `MyCoroutineState::Complete(_)` not covered
--> $DIR/uninhabited-unstable-field.rs:34:11
|
LL | match x {
| ^ pattern `MyCoroutineState::Complete(_)` not covered
|
note: `MyCoroutineState<i32, !>` defined here
--> $DIR/auxiliary/staged-api.rs:11:1
|
LL | pub enum MyCoroutineState<Y, R> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | Yielded(Y),
LL | Complete(R),
| -------- not covered
= note: the matched value is of type `MyCoroutineState<i32, !>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ MyCoroutineState::Yielded(_) => {},
LL + MyCoroutineState::Complete(_) => todo!()
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0004`.

View file

@ -1,11 +1,13 @@
//@ aux-build: staged-api.rs
//@ revisions: current exhaustive
#![feature(exhaustive_patterns)]
#![cfg_attr(exhaustive, feature(exhaustive_patterns))]
#![feature(never_type)]
#![feature(my_coro_state)] // Custom feature from `staged-api.rs`
#![deny(unreachable_patterns)]
extern crate staged_api;
use staged_api::Foo;
use staged_api::{Foo, MyCoroutineState};
enum Void {}
@ -23,7 +25,20 @@ fn demo2(x: Foo<Void>) {
// Same as above, but for wildcard.
fn demo3(x: Foo<Void>) {
match x { _ => {} }
match x {
_ => {}
}
}
fn unstable_enum(x: MyCoroutineState<i32, !>) {
match x {
//~^ ERROR non-exhaustive patterns
MyCoroutineState::Yielded(_) => {}
}
match x {
MyCoroutineState::Yielded(_) => {}
MyCoroutineState::Complete(_) => {}
}
}
fn main() {}