summaryrefslogtreecommitdiffstats
path: root/src/test/ui/binding/empty-types-in-patterns.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/binding/empty-types-in-patterns.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/binding/empty-types-in-patterns.rs')
-rw-r--r--src/test/ui/binding/empty-types-in-patterns.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/test/ui/binding/empty-types-in-patterns.rs b/src/test/ui/binding/empty-types-in-patterns.rs
new file mode 100644
index 000000000..0d0dbcaf4
--- /dev/null
+++ b/src/test/ui/binding/empty-types-in-patterns.rs
@@ -0,0 +1,59 @@
+// run-pass
+
+#![feature(never_type, never_type_fallback)]
+#![feature(exhaustive_patterns)]
+
+#![allow(unreachable_patterns)]
+#![allow(unreachable_code)]
+#![allow(unused_variables)]
+
+#[allow(dead_code)]
+fn foo(z: !) {
+ let x: Result<!, !> = Ok(z);
+
+ let Ok(_y) = x;
+ let Err(_y) = x;
+
+ let x = [z; 1];
+
+ match x {};
+ match x {
+ [q] => q,
+ };
+}
+
+fn bar(nevers: &[!]) {
+ match nevers {
+ &[] => (),
+ };
+
+ match nevers {
+ &[] => (),
+ &[_] => (),
+ &[_, _, _, ..] => (),
+ };
+}
+
+fn main() {
+ let x: Result<u32, !> = Ok(123);
+ let Ok(y) = x;
+
+ assert_eq!(123, y);
+
+ match x {
+ Ok(y) => y,
+ };
+
+ match x {
+ Ok(y) => y,
+ Err(e) => match e {},
+ };
+
+ let x: Result<u32, &!> = Ok(123);
+ match x {
+ Ok(y) => y,
+ Err(_) => unimplemented!(),
+ };
+
+ bar(&[]);
+}