-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillot
Visit expressions in-order when resolving pattern bindings [edited:] Visit the pattern's sub-expressions before defining any bindings. Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked. Fixes #92100
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![feature(half_open_range_patterns)] | ||
|
||
fn main() { | ||
match [1, 2] { | ||
[a.., a] => {} //~ ERROR cannot find value `a` in this scope | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |