diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-24 17:45:27 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-08-05 19:02:23 +0500 |
| commit | 62c92f30cf02fc56b8a774c77097f1111dc2f4ea (patch) | |
| tree | fe8c9846c6ca02b176ea9adcb8a348bd5ead1846 /tests/ui/pattern | |
| parent | 0f353363965ebf05e0757f7679c800b39c51a07e (diff) | |
| download | rust-62c92f30cf02fc56b8a774c77097f1111dc2f4ea.tar.gz rust-62c92f30cf02fc56b8a774c77097f1111dc2f4ea.zip | |
moved 35 tests to organized locations
Diffstat (limited to 'tests/ui/pattern')
4 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/pattern/array-length-mismatch-13482.rs b/tests/ui/pattern/array-length-mismatch-13482.rs new file mode 100644 index 00000000000..244b3237e02 --- /dev/null +++ b/tests/ui/pattern/array-length-mismatch-13482.rs @@ -0,0 +1,7 @@ +fn main() { + let x = [1,2]; + let y = match x { + [] => None, //~ ERROR pattern requires 0 elements but array has 2 + [a,_] => Some(a) + }; +} diff --git a/tests/ui/pattern/array-length-mismatch-verbose-13482-2.rs b/tests/ui/pattern/array-length-mismatch-verbose-13482-2.rs new file mode 100644 index 00000000000..619e9d748ef --- /dev/null +++ b/tests/ui/pattern/array-length-mismatch-verbose-13482-2.rs @@ -0,0 +1,9 @@ +//@ compile-flags:-Z verbose-internals + +fn main() { + let x = [1,2]; + let y = match x { + [] => None, //~ ERROR pattern requires 0 elements but array has 2 + [a,_] => Some(a) + }; +} diff --git a/tests/ui/pattern/struct-mismatch-destructure-14541.rs b/tests/ui/pattern/struct-mismatch-destructure-14541.rs new file mode 100644 index 00000000000..358d29419f9 --- /dev/null +++ b/tests/ui/pattern/struct-mismatch-destructure-14541.rs @@ -0,0 +1,11 @@ +struct Vec2 { y: f32 } +struct Vec3 { y: f32, z: f32 } + +fn make(v: Vec2) { + let Vec3 { y: _, z: _ } = v; + //~^ ERROR mismatched types + //~| NOTE expected `Vec2`, found `Vec3` + //~| NOTE this expression has type `Vec2` +} + +fn main() { } diff --git a/tests/ui/pattern/struct-wildcard-pattern-14308.rs b/tests/ui/pattern/struct-wildcard-pattern-14308.rs new file mode 100644 index 00000000000..724be160d06 --- /dev/null +++ b/tests/ui/pattern/struct-wildcard-pattern-14308.rs @@ -0,0 +1,15 @@ +//@ run-pass + +struct A(isize); + +fn main() { + let x = match A(3) { + A(..) => 1 + }; + assert_eq!(x, 1); + let x = match A(4) { + A(1) => 1, + A(..) => 2 + }; + assert_eq!(x, 2); +} |
