From b1529a680a9a593bd0cb01502dc86b7d0e3ee28d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 23 Dec 2021 16:03:30 -0800 Subject: Visit patterns' literal expressions before binding new idents --- src/test/ui/match/expr_before_ident_pat.rs | 15 +++++++++++++++ src/test/ui/match/expr_before_ident_pat.stderr | 15 +++++++++++++++ src/test/ui/match/issue-92100.rs | 7 +++++++ src/test/ui/match/issue-92100.stderr | 9 +++++++++ 4 files changed, 46 insertions(+) create mode 100644 src/test/ui/match/expr_before_ident_pat.rs create mode 100644 src/test/ui/match/expr_before_ident_pat.stderr create mode 100644 src/test/ui/match/issue-92100.rs create mode 100644 src/test/ui/match/issue-92100.stderr (limited to 'src') diff --git a/src/test/ui/match/expr_before_ident_pat.rs b/src/test/ui/match/expr_before_ident_pat.rs new file mode 100644 index 00000000000..47db6c3f488 --- /dev/null +++ b/src/test/ui/match/expr_before_ident_pat.rs @@ -0,0 +1,15 @@ +#![feature(half_open_range_patterns)] + +macro_rules! funny { + ($a:expr, $b:ident) => { + match [1, 2] { + [$a, $b] => {} + } + }; +} + +fn main() { + funny!(a, a); + //~^ ERROR cannot find value `a` in this scope + //~| ERROR arbitrary expressions aren't allowed in patterns +} diff --git a/src/test/ui/match/expr_before_ident_pat.stderr b/src/test/ui/match/expr_before_ident_pat.stderr new file mode 100644 index 00000000000..1ac8274ffd5 --- /dev/null +++ b/src/test/ui/match/expr_before_ident_pat.stderr @@ -0,0 +1,15 @@ +error: arbitrary expressions aren't allowed in patterns + --> $DIR/expr_before_ident_pat.rs:12:12 + | +LL | funny!(a, a); + | ^ + +error[E0425]: cannot find value `a` in this scope + --> $DIR/expr_before_ident_pat.rs:12:12 + | +LL | funny!(a, a); + | ^ 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/match/issue-92100.rs b/src/test/ui/match/issue-92100.rs new file mode 100644 index 00000000000..021166b2ba5 --- /dev/null +++ b/src/test/ui/match/issue-92100.rs @@ -0,0 +1,7 @@ +#![feature(half_open_range_patterns)] + +fn main() { + match [1, 2] { + [a.., a] => {} //~ ERROR cannot find value `a` in this scope + } +} diff --git a/src/test/ui/match/issue-92100.stderr b/src/test/ui/match/issue-92100.stderr new file mode 100644 index 00000000000..0f694c587fc --- /dev/null +++ b/src/test/ui/match/issue-92100.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `a` in this scope + --> $DIR/issue-92100.rs:5:10 + | +LL | [a.., a] => {} + | ^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. -- cgit 1.4.1-3-g733a5