summaryrefslogtreecommitdiffstats
path: root/src/test/ui/never_type
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/never_type')
-rw-r--r--src/test/ui/never_type/exhaustive_patterns.rs21
-rw-r--r--src/test/ui/never_type/exhaustive_patterns.stderr25
-rw-r--r--src/test/ui/never_type/issue-13352.stderr13
3 files changed, 50 insertions, 9 deletions
diff --git a/src/test/ui/never_type/exhaustive_patterns.rs b/src/test/ui/never_type/exhaustive_patterns.rs
new file mode 100644
index 000000000..2e23fa182
--- /dev/null
+++ b/src/test/ui/never_type/exhaustive_patterns.rs
@@ -0,0 +1,21 @@
+// check-fail
+// known-bug: #104034
+
+#![feature(exhaustive_patterns, never_type)]
+
+mod inner {
+ pub struct Wrapper<T>(T);
+}
+
+enum Either<A, B> {
+ A(A),
+ B(inner::Wrapper<B>),
+}
+
+fn foo() -> Either<(), !> {
+ Either::A(())
+}
+
+fn main() {
+ let Either::A(()) = foo();
+}
diff --git a/src/test/ui/never_type/exhaustive_patterns.stderr b/src/test/ui/never_type/exhaustive_patterns.stderr
new file mode 100644
index 000000000..e41baf862
--- /dev/null
+++ b/src/test/ui/never_type/exhaustive_patterns.stderr
@@ -0,0 +1,25 @@
+error[E0005]: refutable pattern in local binding: `Either::B(_)` not covered
+ --> $DIR/exhaustive_patterns.rs:20:9
+ |
+LL | let Either::A(()) = foo();
+ | ^^^^^^^^^^^^^ pattern `Either::B(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+note: `Either<(), !>` defined here
+ --> $DIR/exhaustive_patterns.rs:12:5
+ |
+LL | enum Either<A, B> {
+ | ------
+LL | A(A),
+LL | B(inner::Wrapper<B>),
+ | ^ not covered
+ = note: the matched value is of type `Either<(), !>`
+help: you might want to use `if let` to ignore the variant that isn't matched
+ |
+LL | if let Either::A(()) = foo() { todo!() }
+ | ++ ~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0005`.
diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr
index fed780e68..2d22da0b4 100644
--- a/src/test/ui/never_type/issue-13352.stderr
+++ b/src/test/ui/never_type/issue-13352.stderr
@@ -6,15 +6,10 @@ LL | 2_usize + (loop {});
|
= help: the trait `Add<()>` is not implemented for `usize`
= help: the following other types implement trait `Add<Rhs>`:
- <&'a f32 as Add<f32>>
- <&'a f64 as Add<f64>>
- <&'a i128 as Add<i128>>
- <&'a i16 as Add<i16>>
- <&'a i32 as Add<i32>>
- <&'a i64 as Add<i64>>
- <&'a i8 as Add<i8>>
- <&'a isize as Add<isize>>
- and 48 others
+ <&'a usize as Add<usize>>
+ <&usize as Add<&usize>>
+ <usize as Add<&usize>>
+ <usize as Add>
error: aborting due to previous error