about summary refs log tree commit diff
path: root/tests/ui/pattern
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-07-24 19:07:20 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-08-09 16:27:20 +0500
commit16765639b30741dde85da0dbcb44c343eb82b1a2 (patch)
treeef7f40e32fab78c39546bc588542774d276e5dc8 /tests/ui/pattern
parent90bb5cacb5c1a5fe20ba821d28e7eb7a21e35d09 (diff)
downloadrust-16765639b30741dde85da0dbcb44c343eb82b1a2.tar.gz
rust-16765639b30741dde85da0dbcb44c343eb82b1a2.zip
comments
Diffstat (limited to 'tests/ui/pattern')
-rw-r--r--tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs (renamed from tests/ui/pattern/enum-struct-pattern-mismatch.rs)2
-rw-r--r--tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr12
-rw-r--r--tests/ui/pattern/refutable-pattern-for-loop-15381.rs2
-rw-r--r--tests/ui/pattern/refutable-pattern-for-loop-15381.stderr11
-rw-r--r--tests/ui/pattern/slice-pattern-recursion-15104.rs2
-rw-r--r--tests/ui/pattern/static-binding-shadow-16149.rs2
-rw-r--r--tests/ui/pattern/static-binding-shadow-16149.stderr12
-rw-r--r--tests/ui/pattern/struct-field-duplicate-binding-15260.rs (renamed from tests/ui/pattern/struct-field-duplicate-binding.rs)2
-rw-r--r--tests/ui/pattern/struct-field-duplicate-binding-15260.stderr36
-rw-r--r--tests/ui/pattern/tuple-enum-match-15129.rs13
-rw-r--r--tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs (renamed from tests/ui/pattern/unit-type-struct-pattern-mismatch.rs)2
-rw-r--r--tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr14
12 files changed, 104 insertions, 6 deletions
diff --git a/tests/ui/pattern/enum-struct-pattern-mismatch.rs b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs
index d3153b516e6..9f7c5084c0e 100644
--- a/tests/ui/pattern/enum-struct-pattern-mismatch.rs
+++ b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs
@@ -1,3 +1,5 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/15896
+
 // Regression test for #15896. It used to ICE rustc.
 
 fn main() {
diff --git a/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr
new file mode 100644
index 00000000000..8dee4c37e2f
--- /dev/null
+++ b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/enum-struct-pattern-mismatch-15896.rs:13:11
+   |
+LL |     let u = match e {
+   |                   - this expression has type `E`
+LL |         E::B(
+LL |           Tau{t: x},
+   |           ^^^^^^^^^ expected `R`, found `Tau`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/pattern/refutable-pattern-for-loop-15381.rs b/tests/ui/pattern/refutable-pattern-for-loop-15381.rs
index bd5f62ddc67..3c19612c9cc 100644
--- a/tests/ui/pattern/refutable-pattern-for-loop-15381.rs
+++ b/tests/ui/pattern/refutable-pattern-for-loop-15381.rs
@@ -1,3 +1,5 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/15381
+
 fn main() {
     let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];
 
diff --git a/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr b/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr
new file mode 100644
index 00000000000..3c1d5fb454c
--- /dev/null
+++ b/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr
@@ -0,0 +1,11 @@
+error[E0005]: refutable pattern in `for` loop binding
+  --> $DIR/refutable-pattern-for-loop-15381.rs:6:9
+   |
+LL |     for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) {
+   |         ^^^^^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered
+   |
+   = note: the matched value is of type `&[u8]`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0005`.
diff --git a/tests/ui/pattern/slice-pattern-recursion-15104.rs b/tests/ui/pattern/slice-pattern-recursion-15104.rs
index e68c94c370e..24e3fe78de0 100644
--- a/tests/ui/pattern/slice-pattern-recursion-15104.rs
+++ b/tests/ui/pattern/slice-pattern-recursion-15104.rs
@@ -1,3 +1,5 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/15104
+
 //@ run-pass
 
 fn main() {
diff --git a/tests/ui/pattern/static-binding-shadow-16149.rs b/tests/ui/pattern/static-binding-shadow-16149.rs
index 51b60725c5a..a46f78214c7 100644
--- a/tests/ui/pattern/static-binding-shadow-16149.rs
+++ b/tests/ui/pattern/static-binding-shadow-16149.rs
@@ -1,3 +1,5 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/16149
+
 extern "C" {
     static externalValue: isize;
 }
diff --git a/tests/ui/pattern/static-binding-shadow-16149.stderr b/tests/ui/pattern/static-binding-shadow-16149.stderr
new file mode 100644
index 00000000000..6d8c7634acd
--- /dev/null
+++ b/tests/ui/pattern/static-binding-shadow-16149.stderr
@@ -0,0 +1,12 @@
+error[E0530]: match bindings cannot shadow statics
+  --> $DIR/static-binding-shadow-16149.rs:9:9
+   |
+LL |     static externalValue: isize;
+   |     ---------------------------- the static `externalValue` is defined here
+...
+LL |         externalValue => true,
+   |         ^^^^^^^^^^^^^ cannot be named the same as a static
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0530`.
diff --git a/tests/ui/pattern/struct-field-duplicate-binding.rs b/tests/ui/pattern/struct-field-duplicate-binding-15260.rs
index 64fc3df3d23..a3617798cdf 100644
--- a/tests/ui/pattern/struct-field-duplicate-binding.rs
+++ b/tests/ui/pattern/struct-field-duplicate-binding-15260.rs
@@ -1,3 +1,5 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/15260
+
 struct Foo {
     a: usize,
 }
diff --git a/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr b/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr
new file mode 100644
index 00000000000..536904fbcb3
--- /dev/null
+++ b/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr
@@ -0,0 +1,36 @@
+error[E0025]: field `a` bound multiple times in the pattern
+  --> $DIR/struct-field-duplicate-binding-15260.rs:10:9
+   |
+LL |         a: _,
+   |         ---- first use of `a`
+LL |         a: _
+   |         ^^^^ multiple uses of `a` in pattern
+
+error[E0025]: field `a` bound multiple times in the pattern
+  --> $DIR/struct-field-duplicate-binding-15260.rs:16:9
+   |
+LL |         a,
+   |         - first use of `a`
+LL |         a: _
+   |         ^^^^ multiple uses of `a` in pattern
+
+error[E0025]: field `a` bound multiple times in the pattern
+  --> $DIR/struct-field-duplicate-binding-15260.rs:22:9
+   |
+LL |         a,
+   |         - first use of `a`
+LL |         a: _,
+   |         ^^^^ multiple uses of `a` in pattern
+
+error[E0025]: field `a` bound multiple times in the pattern
+  --> $DIR/struct-field-duplicate-binding-15260.rs:24:9
+   |
+LL |         a,
+   |         - first use of `a`
+...
+LL |         a: x
+   |         ^^^^ multiple uses of `a` in pattern
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0025`.
diff --git a/tests/ui/pattern/tuple-enum-match-15129.rs b/tests/ui/pattern/tuple-enum-match-15129.rs
index e2ddb989072..1d6192c4cb3 100644
--- a/tests/ui/pattern/tuple-enum-match-15129.rs
+++ b/tests/ui/pattern/tuple-enum-match-15129.rs
@@ -1,24 +1,25 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/15129
+
 //@ run-pass
 
 pub enum T {
     T1(()),
-    T2(())
+    T2(()),
 }
 
 pub enum V {
     V1(isize),
-    V2(bool)
+    V2(bool),
 }
 
 fn foo(x: (T, V)) -> String {
     match x {
-        (T::T1(()), V::V1(i))  => format!("T1(()), V1({})", i),
-        (T::T2(()), V::V2(b))  => format!("T2(()), V2({})", b),
-        _ => String::new()
+        (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i),
+        (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b),
+        _ => String::new(),
     }
 }
 
-
 fn main() {
     assert_eq!(foo((T::T1(()), V::V1(99))), "T1(()), V1(99)".to_string());
     assert_eq!(foo((T::T2(()), V::V2(true))), "T2(()), V2(true)".to_string());
diff --git a/tests/ui/pattern/unit-type-struct-pattern-mismatch.rs b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs
index 0985a6806d2..2eba33e177e 100644
--- a/tests/ui/pattern/unit-type-struct-pattern-mismatch.rs
+++ b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs
@@ -1,3 +1,5 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/16401
+
 struct Slice<T> {
     data: *const T,
     len: usize,
diff --git a/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr
new file mode 100644
index 00000000000..22c04e439c4
--- /dev/null
+++ b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/unit-type-struct-pattern-mismatch-16401.rs:10:9
+   |
+LL |     match () {
+   |           -- this expression has type `()`
+LL |         Slice { data: data, len: len } => (),
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Slice<_>`
+   |
+   = note: expected unit type `()`
+                 found struct `Slice<_>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.