summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rfc-2294-if-let-guard
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/rfc-2294-if-let-guard
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/rfc-2294-if-let-guard')
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/bindings.rs9
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/bindings.stderr15
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/feature-gate.rs84
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr288
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/run-pass.rs40
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/typeck.rs15
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/typeck.stderr25
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/warns.rs21
-rw-r--r--src/test/ui/rfc-2294-if-let-guard/warns.stderr28
9 files changed, 0 insertions, 525 deletions
diff --git a/src/test/ui/rfc-2294-if-let-guard/bindings.rs b/src/test/ui/rfc-2294-if-let-guard/bindings.rs
deleted file mode 100644
index 1f32e4af1..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/bindings.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(if_let_guard)]
-
-fn main() {
- match Some(None) {
- Some(x) if let Some(y) = x => (x, y),
- _ => y, //~ ERROR cannot find value `y`
- }
- y //~ ERROR cannot find value `y`
-}
diff --git a/src/test/ui/rfc-2294-if-let-guard/bindings.stderr b/src/test/ui/rfc-2294-if-let-guard/bindings.stderr
deleted file mode 100644
index 2463b7f3e..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/bindings.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0425]: cannot find value `y` in this scope
- --> $DIR/bindings.rs:6:14
- |
-LL | _ => y,
- | ^ not found in this scope
-
-error[E0425]: cannot find value `y` in this scope
- --> $DIR/bindings.rs:8:5
- |
-LL | y
- | ^ not found in this scope
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/rfc-2294-if-let-guard/feature-gate.rs b/src/test/ui/rfc-2294-if-let-guard/feature-gate.rs
deleted file mode 100644
index f0105e08e..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/feature-gate.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-// gate-test-if_let_guard
-
-use std::ops::Range;
-
-fn _if_let_guard() {
- match () {
- () if let 0 = 1 => {}
- //~^ ERROR `if let` guards are experimental
-
- () if (let 0 = 1) => {}
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
-
- () if (((let 0 = 1))) => {}
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
-
- () if true && let 0 = 1 => {}
- //~^ ERROR `if let` guards are experimental
- //~| ERROR `let` expressions in this position are unstable
-
- () if let 0 = 1 && true => {}
- //~^ ERROR `if let` guards are experimental
- //~| ERROR `let` expressions in this position are unstable
-
- () if (let 0 = 1) && true => {}
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
-
- () if true && (let 0 = 1) => {}
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
-
- () if (let 0 = 1) && (let 0 = 1) => {}
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
- //~| ERROR expected expression, found `let` statement
-
- () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- //~^ ERROR `if let` guards are experimental
- //~| ERROR `let` expressions in this position are unstable
- //~| ERROR `let` expressions in this position are unstable
- //~| ERROR `let` expressions in this position are unstable
- //~| ERROR `let` expressions in this position are unstable
- //~| ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
- //~| ERROR expected expression, found `let` statement
- //~| ERROR expected expression, found `let` statement
-
- () if let Range { start: _, end: _ } = (true..true) && false => {}
- //~^ ERROR `if let` guards are experimental
- //~| ERROR `let` expressions in this position are unstable
-
- _ => {}
- }
-}
-
-fn _macros() {
- macro_rules! use_expr {
- ($e:expr) => {
- match () {
- () if $e => {}
- _ => {}
- }
- }
- }
- use_expr!((let 0 = 1 && 0 == 0));
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
- use_expr!((let 0 = 1));
- //~^ ERROR `let` expressions in this position are unstable
- //~| ERROR expected expression, found `let` statement
- match () {
- #[cfg(FALSE)]
- () if let 0 = 1 => {}
- //~^ ERROR `if let` guards are experimental
- _ => {}
- }
- use_expr!(let 0 = 1);
- //~^ ERROR no rules expected the token `let`
-}
-
-fn main() {}
diff --git a/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr b/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr
deleted file mode 100644
index 96fe11911..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/feature-gate.stderr
+++ /dev/null
@@ -1,288 +0,0 @@
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:10:16
- |
-LL | () if (let 0 = 1) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:14:18
- |
-LL | () if (((let 0 = 1))) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:26:16
- |
-LL | () if (let 0 = 1) && true => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:30:24
- |
-LL | () if true && (let 0 = 1) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:34:16
- |
-LL | () if (let 0 = 1) && (let 0 = 1) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:34:31
- |
-LL | () if (let 0 = 1) && (let 0 = 1) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:40:42
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:40:55
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:40:68
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:68:16
- |
-LL | use_expr!((let 0 = 1 && 0 == 0));
- | ^^^
-
-error: expected expression, found `let` statement
- --> $DIR/feature-gate.rs:71:16
- |
-LL | use_expr!((let 0 = 1));
- | ^^^
-
-error: no rules expected the token `let`
- --> $DIR/feature-gate.rs:80:15
- |
-LL | macro_rules! use_expr {
- | --------------------- when calling this macro
-...
-LL | use_expr!(let 0 = 1);
- | ^^^ no rules expected this token in macro call
- |
-note: while trying to match meta-variable `$e:expr`
- --> $DIR/feature-gate.rs:61:10
- |
-LL | ($e:expr) => {
- | ^^^^^^^
-
-error[E0658]: `if let` guards are experimental
- --> $DIR/feature-gate.rs:7:12
- |
-LL | () if let 0 = 1 => {}
- | ^^^^^^^^^^^^
- |
- = note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
- = help: add `#![feature(if_let_guard)]` to the crate attributes to enable
- = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
-
-error[E0658]: `if let` guards are experimental
- --> $DIR/feature-gate.rs:18:12
- |
-LL | () if true && let 0 = 1 => {}
- | ^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
- = help: add `#![feature(if_let_guard)]` to the crate attributes to enable
- = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
-
-error[E0658]: `if let` guards are experimental
- --> $DIR/feature-gate.rs:22:12
- |
-LL | () if let 0 = 1 && true => {}
- | ^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
- = help: add `#![feature(if_let_guard)]` to the crate attributes to enable
- = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
-
-error[E0658]: `if let` guards are experimental
- --> $DIR/feature-gate.rs:40:12
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
- = help: add `#![feature(if_let_guard)]` to the crate attributes to enable
- = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
-
-error[E0658]: `if let` guards are experimental
- --> $DIR/feature-gate.rs:51:12
- |
-LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
- = help: add `#![feature(if_let_guard)]` to the crate attributes to enable
- = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
-
-error[E0658]: `if let` guards are experimental
- --> $DIR/feature-gate.rs:76:12
- |
-LL | () if let 0 = 1 => {}
- | ^^^^^^^^^^^^
- |
- = note: see issue #51114 <https://github.com/rust-lang/rust/issues/51114> for more information
- = help: add `#![feature(if_let_guard)]` to the crate attributes to enable
- = help: you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:10:16
- |
-LL | () if (let 0 = 1) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:14:18
- |
-LL | () if (((let 0 = 1))) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:18:23
- |
-LL | () if true && let 0 = 1 => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:22:15
- |
-LL | () if let 0 = 1 && true => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:26:16
- |
-LL | () if (let 0 = 1) && true => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:30:24
- |
-LL | () if true && (let 0 = 1) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:34:16
- |
-LL | () if (let 0 = 1) && (let 0 = 1) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:34:31
- |
-LL | () if (let 0 = 1) && (let 0 = 1) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:40:15
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:40:28
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:40:42
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:40:55
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:40:68
- |
-LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {}
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:51:15
- |
-LL | () if let Range { start: _, end: _ } = (true..true) && false => {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:68:16
- |
-LL | use_expr!((let 0 = 1 && 0 == 0));
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error[E0658]: `let` expressions in this position are unstable
- --> $DIR/feature-gate.rs:71:16
- |
-LL | use_expr!((let 0 = 1));
- | ^^^^^^^^^
- |
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
- = help: add `#![feature(let_chains)]` to the crate attributes to enable
-
-error: aborting due to 34 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/rfc-2294-if-let-guard/run-pass.rs b/src/test/ui/rfc-2294-if-let-guard/run-pass.rs
deleted file mode 100644
index a303a0d1f..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/run-pass.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-// run-pass
-
-#![feature(if_let_guard)]
-
-enum Foo {
- Bar,
- Baz,
- Qux(u8),
-}
-
-fn bar(x: bool) -> Foo {
- if x { Foo::Baz } else { Foo::Bar }
-}
-
-fn baz(x: u8) -> Foo {
- if x % 2 == 0 { Foo::Bar } else { Foo::Baz }
-}
-
-fn qux(x: u8) -> Foo {
- Foo::Qux(x.rotate_left(1))
-}
-
-fn main() {
- match Some((true, 3)) {
- Some((x, _)) if let Foo::Bar = bar(x) => panic!(),
- Some((_, x)) if let Foo::Baz = baz(x) => {},
- _ => panic!(),
- }
- match Some(42) {
- Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84),
- _ => panic!(),
- }
-
- // issue #88015
- #[allow(irrefutable_let_patterns)]
- match () {
- () | () if let x = 42 => assert_eq!(x, 42),
- _ => panic!()
- }
-}
diff --git a/src/test/ui/rfc-2294-if-let-guard/typeck.rs b/src/test/ui/rfc-2294-if-let-guard/typeck.rs
deleted file mode 100644
index ad178dfa4..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/typeck.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-#![feature(if_let_guard)]
-
-fn ok() -> Result<Option<bool>, ()> {
- Ok(Some(true))
-}
-
-fn main() {
- match ok() {
- Ok(x) if let Err(_) = x => {},
- //~^ ERROR mismatched types
- Ok(x) if let 0 = x => {},
- //~^ ERROR mismatched types
- _ => {}
- }
-}
diff --git a/src/test/ui/rfc-2294-if-let-guard/typeck.stderr b/src/test/ui/rfc-2294-if-let-guard/typeck.stderr
deleted file mode 100644
index dd1f4826f..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/typeck.stderr
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/typeck.rs:9:22
- |
-LL | Ok(x) if let Err(_) = x => {},
- | ^^^^^^ - this expression has type `Option<bool>`
- | |
- | expected enum `Option`, found enum `Result`
- |
- = note: expected enum `Option<bool>`
- found enum `Result<_, _>`
-
-error[E0308]: mismatched types
- --> $DIR/typeck.rs:11:22
- |
-LL | Ok(x) if let 0 = x => {},
- | ^ - this expression has type `Option<bool>`
- | |
- | expected enum `Option`, found integer
- |
- = note: expected enum `Option<bool>`
- found type `{integer}`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/rfc-2294-if-let-guard/warns.rs b/src/test/ui/rfc-2294-if-let-guard/warns.rs
deleted file mode 100644
index 3ad1a50c6..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/warns.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-#![feature(if_let_guard)]
-
-#[deny(irrefutable_let_patterns)]
-fn irrefutable_let_guard() {
- match Some(()) {
- Some(x) if let () = x => {}
- //~^ ERROR irrefutable `if let` guard
- _ => {}
- }
-}
-
-#[deny(unreachable_patterns)]
-fn unreachable_pattern() {
- match Some(()) {
- x if let None | None = x => {}
- //~^ ERROR unreachable pattern
- _ => {}
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/rfc-2294-if-let-guard/warns.stderr b/src/test/ui/rfc-2294-if-let-guard/warns.stderr
deleted file mode 100644
index 75f22ac8d..000000000
--- a/src/test/ui/rfc-2294-if-let-guard/warns.stderr
+++ /dev/null
@@ -1,28 +0,0 @@
-error: irrefutable `if let` guard pattern
- --> $DIR/warns.rs:6:24
- |
-LL | Some(x) if let () = x => {}
- | ^^
- |
- = note: this pattern will always match, so the guard is useless
- = help: consider removing the guard and adding a `let` inside the match arm
-note: the lint level is defined here
- --> $DIR/warns.rs:3:8
- |
-LL | #[deny(irrefutable_let_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: unreachable pattern
- --> $DIR/warns.rs:15:25
- |
-LL | x if let None | None = x => {}
- | ^^^^
- |
-note: the lint level is defined here
- --> $DIR/warns.rs:12:8
- |
-LL | #[deny(unreachable_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-