diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-06-01 00:03:54 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-06-03 07:38:06 +0500 |
| commit | e7e884b0a4b5f012864562b0bb550d80d3e5f03b (patch) | |
| tree | 20e189b8ec9a54f4e63b4136e2756c246396c210 /tests/ui/pattern | |
| parent | 852f15c0f146fc292c9b20f2a8f44c1f671d7845 (diff) | |
| download | rust-e7e884b0a4b5f012864562b0bb550d80d3e5f03b.tar.gz rust-e7e884b0a4b5f012864562b0bb550d80d3e5f03b.zip | |
cleaned up some tests
Diffstat (limited to 'tests/ui/pattern')
| -rw-r--r-- | tests/ui/pattern/pattern-match-arc-move.rs | 15 | ||||
| -rw-r--r-- | tests/ui/pattern/pattern-match-invalid-variant.rs | 19 | ||||
| -rw-r--r-- | tests/ui/pattern/pattern-match-invalid-variant.stderr | 12 |
3 files changed, 46 insertions, 0 deletions
diff --git a/tests/ui/pattern/pattern-match-arc-move.rs b/tests/ui/pattern/pattern-match-arc-move.rs new file mode 100644 index 00000000000..bc79401e4e3 --- /dev/null +++ b/tests/ui/pattern/pattern-match-arc-move.rs @@ -0,0 +1,15 @@ +//! Tests moving an `Arc` value out of an `Option` in a match expression. + +//@ run-pass + +use std::sync::Arc; +fn dispose(_x: Arc<bool>) { } + +pub fn main() { + let p = Arc::new(true); + let x = Some(p); + match x { + Some(z) => { dispose(z); }, + None => panic!() + } +} diff --git a/tests/ui/pattern/pattern-match-invalid-variant.rs b/tests/ui/pattern/pattern-match-invalid-variant.rs new file mode 100644 index 00000000000..183031553c0 --- /dev/null +++ b/tests/ui/pattern/pattern-match-invalid-variant.rs @@ -0,0 +1,19 @@ +//! Tests invalid enum variant in a match expression. + +enum Color { + Rgb(isize, isize, isize), + Rgba(isize, isize, isize, isize), +} + +fn main() { + let red: Color = Color::Rgb(255, 0, 0); + match red { + Color::Rgb(r, g, b) => { + println!("rgb"); + } + Color::Hsl(h, s, l) => { + //~^ ERROR no variant + println!("hsl"); + } + } +} diff --git a/tests/ui/pattern/pattern-match-invalid-variant.stderr b/tests/ui/pattern/pattern-match-invalid-variant.stderr new file mode 100644 index 00000000000..08a99f696f6 --- /dev/null +++ b/tests/ui/pattern/pattern-match-invalid-variant.stderr @@ -0,0 +1,12 @@ +error[E0599]: no variant or associated item named `Hsl` found for enum `Color` in the current scope + --> $DIR/pattern-match-invalid-variant.rs:14:16 + | +LL | enum Color { + | ---------- variant or associated item `Hsl` not found for this enum +... +LL | Color::Hsl(h, s, l) => { + | ^^^ variant or associated item not found in `Color` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. |
