Repository navigation
Conversation
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
What does |
|
Uhh good question. It should be rejected, but I'll add a test and make sure that is the case. |
|
I would expect it to be a normal metavariable, like |
|
The implementation is clearly a hack, but if the hack is applied immediately after the token leaves One problem that I see is that the token stream representation ( Is there specific motivation to support these, or is it just "why not"? |
|
This needs testing if we want to go forward with this. Name resolution:
Parsing:
|
|
Any other uses of |
I tried using I can add a slew of test cases, assuming this is something the team wants in principle? |
|
What about |
|
It would also be good to have a test that e.g. |
TIL raw identifiers can be used as metavariable names as well. I assumed they wouldn't be supported because How do you feel about making the For |
|
@jhpratt Could you add rustfmt tests? I'd want to make sure rustfmt isn't accidentally removing Maybe just add the following to struct r#crate {}
struct r#self {}
struct r#Self {}
struct r#super {}or something like this: use some::r#crate;
use some::r#self;
use some::r#Self;
use some::r#super;
use r#crate::r#super::r#self::r#Self; |
|
☔ The latest upstream changes (presumably #166371) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
Currently,
r#crate,r#self,r#Self, andr#superare prohibited regardless of circumstance. This is due to the fact that all four idents are allowed in paths and the fact that an identifier is raw is stripped away very early on in the compilation process.A trivial attempt at bypassing that would have resulted in quite a bit of work, so I took a different approach: consider the four raw identifiers an identifier of their own. In other words,
r#selfis not the same asself, even thoughr#foois the same asfoo. This was surprisingly easy to implement…I only had to add four symbols and intercept them in the parser. Proc macros weren't much harder.Other than tests specifically targeting the lack of support for these raw identifiers, no UI tests were altered.
As a language change, this will require FCP from T-lang. There's probably some other documentation that needs updating, in particular the reference, which is believed to explicitly document the current behavior. Technically it involves changing the API of
proc_macroin that more raw idents are supported, but that feels so trivial that T-libs doesn't need to be involved in my opinion.cc @rust-lang/lang and @rust-lang/lang-advisors
Initial discussion on Zulip.
Disclosure: An LLM was used to find the appropriate parts of code to edit, but all code was written by hand (minus blessing tests, of course). This is well within the policy.