diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-10-18 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-10-19 20:45:43 +0200 |
| commit | c97cf7fed7f151e493e08b95ce4f04856974faab (patch) | |
| tree | 0211d9448dff5d77d7231f0fb319d292be30f4b1 /src | |
| parent | 1af55d19c7a9189374d89472f97dc119659bb67e (diff) | |
| download | rust-c97cf7fed7f151e493e08b95ce4f04856974faab.tar.gz rust-c97cf7fed7f151e493e08b95ce4f04856974faab.zip | |
Reject closures in patterns
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/consts/closure-structural-match-issue-90013.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/pattern/non-structural-match-types.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/pattern/non-structural-match-types.stderr | 14 |
3 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/consts/closure-structural-match-issue-90013.rs b/src/test/ui/consts/closure-structural-match-issue-90013.rs new file mode 100644 index 00000000000..7853ee41a90 --- /dev/null +++ b/src/test/ui/consts/closure-structural-match-issue-90013.rs @@ -0,0 +1,8 @@ +// Regression test for issue 90013. +// check-pass +#![allow(incomplete_features)] +#![feature(inline_const)] + +fn main() { + const { || {} }; +} diff --git a/src/test/ui/pattern/non-structural-match-types.rs b/src/test/ui/pattern/non-structural-match-types.rs new file mode 100644 index 00000000000..713418fc5b2 --- /dev/null +++ b/src/test/ui/pattern/non-structural-match-types.rs @@ -0,0 +1,14 @@ +// edition:2021 +#![allow(incomplete_features)] +#![allow(unreachable_code)] +#![feature(const_async_blocks)] +#![feature(inline_const)] + +fn main() { + match loop {} { + const { || {} } => {}, //~ ERROR cannot be used in patterns + } + match loop {} { + const { async {} } => {}, //~ ERROR cannot be used in patterns + } +} diff --git a/src/test/ui/pattern/non-structural-match-types.stderr b/src/test/ui/pattern/non-structural-match-types.stderr new file mode 100644 index 00000000000..91fed81eaef --- /dev/null +++ b/src/test/ui/pattern/non-structural-match-types.stderr @@ -0,0 +1,14 @@ +error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used in patterns + --> $DIR/non-structural-match-types.rs:9:9 + | +LL | const { || {} } => {}, + | ^^^^^^^^^^^^^^^ + +error: `impl Future` cannot be used in patterns + --> $DIR/non-structural-match-types.rs:12:9 + | +LL | const { async {} } => {}, + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + |
