about summary refs log tree commit diff
path: root/tests/ui/match
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-07-24 17:45:27 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-08-05 19:02:23 +0500
commit62c92f30cf02fc56b8a774c77097f1111dc2f4ea (patch)
treefe8c9846c6ca02b176ea9adcb8a348bd5ead1846 /tests/ui/match
parent0f353363965ebf05e0757f7679c800b39c51a07e (diff)
downloadrust-62c92f30cf02fc56b8a774c77097f1111dc2f4ea.tar.gz
rust-62c92f30cf02fc56b8a774c77097f1111dc2f4ea.zip
moved 35 tests to organized locations
Diffstat (limited to 'tests/ui/match')
-rw-r--r--tests/ui/match/guard-pattern-ordering-14865.rs23
-rw-r--r--tests/ui/match/multiple-refutable-patterns-13867.rs48
-rw-r--r--tests/ui/match/tuple-usize-pattern-14393.rs9
3 files changed, 80 insertions, 0 deletions
diff --git a/tests/ui/match/guard-pattern-ordering-14865.rs b/tests/ui/match/guard-pattern-ordering-14865.rs
new file mode 100644
index 00000000000..e0f8bfe9428
--- /dev/null
+++ b/tests/ui/match/guard-pattern-ordering-14865.rs
@@ -0,0 +1,23 @@
+//@ run-pass
+#![allow(dead_code)]
+
+enum X {
+    Foo(usize),
+    Bar(bool)
+}
+
+fn main() {
+    let x = match X::Foo(42) {
+        X::Foo(..) => 1,
+        _ if true => 0,
+        X::Bar(..) => panic!("Oh dear")
+    };
+    assert_eq!(x, 1);
+
+    let x = match X::Foo(42) {
+        _ if true => 0,
+        X::Foo(..) => 1,
+        X::Bar(..) => panic!("Oh dear")
+    };
+    assert_eq!(x, 0);
+}
diff --git a/tests/ui/match/multiple-refutable-patterns-13867.rs b/tests/ui/match/multiple-refutable-patterns-13867.rs
new file mode 100644
index 00000000000..ad7d6d66393
--- /dev/null
+++ b/tests/ui/match/multiple-refutable-patterns-13867.rs
@@ -0,0 +1,48 @@
+//@ run-pass
+// Test that codegen works correctly when there are multiple refutable
+// patterns in match expression.
+
+enum Foo {
+    FooUint(usize),
+    FooNullary,
+}
+
+fn main() {
+    let r = match (Foo::FooNullary, 'a') {
+        (Foo::FooUint(..), 'a'..='z') => 1,
+        (Foo::FooNullary, 'x') => 2,
+        _ => 0
+    };
+    assert_eq!(r, 0);
+
+    let r = match (Foo::FooUint(0), 'a') {
+        (Foo::FooUint(1), 'a'..='z') => 1,
+        (Foo::FooUint(..), 'x') => 2,
+        (Foo::FooNullary, 'a') => 3,
+        _ => 0
+    };
+    assert_eq!(r, 0);
+
+    let r = match ('a', Foo::FooUint(0)) {
+        ('a'..='z', Foo::FooUint(1)) => 1,
+        ('x', Foo::FooUint(..)) => 2,
+        ('a', Foo::FooNullary) => 3,
+        _ => 0
+    };
+    assert_eq!(r, 0);
+
+    let r = match ('a', 'a') {
+        ('a'..='z', 'b') => 1,
+        ('x', 'a'..='z') => 2,
+        _ => 0
+    };
+    assert_eq!(r, 0);
+
+    let r = match ('a', 'a') {
+        ('a'..='z', 'b') => 1,
+        ('x', 'a'..='z') => 2,
+        ('a', 'a') => 3,
+        _ => 0
+    };
+    assert_eq!(r, 3);
+}
diff --git a/tests/ui/match/tuple-usize-pattern-14393.rs b/tests/ui/match/tuple-usize-pattern-14393.rs
new file mode 100644
index 00000000000..69c3fc15d31
--- /dev/null
+++ b/tests/ui/match/tuple-usize-pattern-14393.rs
@@ -0,0 +1,9 @@
+//@ run-pass
+
+fn main() {
+    match ("", 1_usize) {
+        (_, 42_usize) => (),
+        ("", _) => (),
+        _ => ()
+    }
+}