diff options
| author | Michael Goulet <michael@errs.io> | 2021-12-23 16:03:30 -0800 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2021-12-27 12:20:13 -0800 |
| commit | b1529a680a9a593bd0cb01502dc86b7d0e3ee28d (patch) | |
| tree | baefc06e62adb6dc181275e7763c3456836649d8 /src | |
| parent | 77497c74f9268ccf91d7b4c17f23bf07117d7433 (diff) | |
| download | rust-b1529a680a9a593bd0cb01502dc86b7d0e3ee28d.tar.gz rust-b1529a680a9a593bd0cb01502dc86b7d0e3ee28d.zip | |
Visit patterns' literal expressions before binding new idents
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/match/expr_before_ident_pat.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/match/expr_before_ident_pat.stderr | 15 | ||||
| -rw-r--r-- | src/test/ui/match/issue-92100.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/match/issue-92100.stderr | 9 |
4 files changed, 46 insertions, 0 deletions
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`. |
