From c97cf7fed7f151e493e08b95ce4f04856974faab Mon Sep 17 00:00:00 2001 From: Tomasz Miąsko Date: Mon, 18 Oct 2021 00:00:00 +0000 Subject: Reject closures in patterns --- src/test/ui/pattern/non-structural-match-types.rs | 14 ++++++++++++++ src/test/ui/pattern/non-structural-match-types.stderr | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/test/ui/pattern/non-structural-match-types.rs create mode 100644 src/test/ui/pattern/non-structural-match-types.stderr (limited to 'src/test/ui/pattern') 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 + -- cgit 1.4.1-3-g733a5