-
Notifications
You must be signed in to change notification settings - Fork 554
Change underscore to be a keyword #2049
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ MacroMatcher -> | |
MacroMatch -> | ||
Token _except `$` and [delimiters][lex.token.delim]_ | ||
| MacroMatcher | ||
| `$` ( IDENTIFIER_OR_KEYWORD _except `crate`_ | RAW_IDENTIFIER | `_` ) `:` MacroFragSpec | ||
| `$` ( IDENTIFIER_OR_KEYWORD _except `crate`_ | RAW_IDENTIFIER ) `:` MacroFragSpec | ||
| `$` `(` MacroMatch+ `)` MacroRepSep? MacroRepOp | ||
|
||
MacroFragSpec -> | ||
|
@@ -134,7 +134,7 @@ Valid fragment specifiers are: | |
* `block`: a [BlockExpression] | ||
* `expr`: an [Expression] | ||
* `expr_2021`: an [Expression] except [UnderscoreExpression] and [ConstBlockExpression] (see [macro.decl.meta.edition2024]) | ||
* `ident`: an [IDENTIFIER_OR_KEYWORD], [RAW_IDENTIFIER], or [`$crate`] | ||
* `ident`: an [IDENTIFIER_OR_KEYWORD] except `_`, [RAW_IDENTIFIER], or [`$crate`] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing, but this doesn't seem correct, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
* `item`: an [Item] | ||
* `lifetime`: a [LIFETIME_TOKEN] | ||
* `literal`: matches `-`<sup>?</sup>[LiteralExpression] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RESERVED_RAW_IDENTIFIER
a few lines below may be redundant now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I spent some time thinking about this and how to correctly express that these keywords are rejected. The current except clause didn't express that in the way that I was intending. I pushed up a commit that instead of removing the reserved rule, it moves the except part into the reserved rule.
Or, to put it in another way,
r#crate
is a token, it's just rejected as an error. The previous lexical grammar wasn't really conveying that.