-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Update expr
matcher for Edition 2024 and add expr_2021
nonterminal
#123865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef6478b
Add expr_2021 nonterminal and feature flag
eholk 65da4ad
Add test that expr_2021 only works on 2024 edition
eholk 73303c3
expr_2021 should be allowed on edition 2021 and later
eholk a55d063
Macros: match const { ... } with expr nonterminal in edition 2024
vincenzopalazzo f364011
Apply code review suggestions
eholk 3986ea0
Update compiler/rustc_parse/src/parser/nonterminal.rs
eholk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add test that expr_2021 only works on 2024 edition
Co-authored-by: Vincenzo Palazzo <[email protected]>
- Loading branch information
commit 65da4adfcd12a062874524a37ebd4f522c04205f
There are no files selected for viewing
This file contains hidden or 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,13 @@ | ||
//@ compile-flags: --edition=2021 | ||
|
||
// This test ensures that expr_2021 is not allowed on pre-2024 editions | ||
|
||
macro_rules! m { | ||
($e:expr_2021) => { //~ ERROR: invalid fragment specifier `expr_2021` | ||
$e | ||
}; | ||
} | ||
|
||
fn main() { | ||
m!(()); //~ ERROR: no rules expected the token `(` | ||
} |
This file contains hidden or 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,25 @@ | ||
error: invalid fragment specifier `expr_2021` | ||
--> $DIR/expr_2021_old_edition.rs:6:6 | ||
| | ||
LL | ($e:expr_2021) => { | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` | ||
|
||
error: no rules expected the token `(` | ||
--> $DIR/expr_2021_old_edition.rs:12:8 | ||
| | ||
LL | macro_rules! m { | ||
| -------------- when calling this macro | ||
... | ||
LL | m!(()); | ||
| ^ no rules expected this token in macro call | ||
| | ||
note: while trying to match meta-variable `$e:ident` | ||
--> $DIR/expr_2021_old_edition.rs:6:6 | ||
| | ||
LL | ($e:expr_2021) => { | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.