about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2025-07-20 14:41:27 +0200
committerNadrieril <nadrieril+git@gmail.com>2025-07-20 14:49:43 +0200
commite9fb744207b64ff60e7f3dcec3897d76131b165a (patch)
treeb6b331e7da815af7b90377f2513055f7bc9fd567
parent81af9d45698a19183b8552079cbc7bf893fad1e5 (diff)
downloadrust-e9fb744207b64ff60e7f3dcec3897d76131b165a.tar.gz
rust-e9fb744207b64ff60e7f3dcec3897d76131b165a.zip
Add test
-rw-r--r--tests/ui/uninhabited/auxiliary/staged-api.rs6
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.current.stderr25
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr25
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.rs23
4 files changed, 71 insertions, 8 deletions
diff --git a/tests/ui/uninhabited/auxiliary/staged-api.rs b/tests/ui/uninhabited/auxiliary/staged-api.rs
index 342ecf020ea..925bb1e0c65 100644
--- a/tests/ui/uninhabited/auxiliary/staged-api.rs
+++ b/tests/ui/uninhabited/auxiliary/staged-api.rs
@@ -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),
+}
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr
index 9e0feb4c473..704475ece48 100644
--- a/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr
+++ b/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr
@@ -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`.
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr
index 9e0feb4c473..704475ece48 100644
--- a/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr
+++ b/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr
@@ -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`.
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.rs b/tests/ui/uninhabited/uninhabited-unstable-field.rs
index 9b507c518ab..44527319ffd 100644
--- a/tests/ui/uninhabited/uninhabited-unstable-field.rs
+++ b/tests/ui/uninhabited/uninhabited-unstable-field.rs
@@ -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() {}