Better errors with bad/missing identifiers in MBEs#118939
Better errors with bad/missing identifiers in MBEs#118939EliseZeroTwo wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
aeb58d5 to
a51902a
Compare
This comment has been minimized.
This comment has been minimized.
|
In #62258 |
a51902a to
953a1ef
Compare
This comment has been minimized.
This comment has been minimized.
|
@EliseZeroTwo A test |
|
@rustbot author |
ee200da to
3452e01
Compare
3452e01 to
661b30a
Compare
|
@rustbot label -S-waiting-on-author +S-waiting-on-review |
This comment has been minimized.
This comment has been minimized.
661b30a to
db53e3f
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot author |
db53e3f to
4c4b155
Compare
This comment has been minimized.
This comment has been minimized.
4c4b155 to
7073fb9
Compare
|
@rustbot review |
7073fb9 to
3714817
Compare
|
This is a breaking language change, if I understand correctly. |
As documentation seems to indicate that this is how it is meant to be, I did not think it was. I took a look before submitting this and also could not find published software using this, but maybe testing the change against crates.io would be a good idea anyways? It does undo the change you implemented in #62258 which reallowed |
Well, not by me, at least. In any case, such changes should go through the language team. |
|
☔ The latest upstream changes (presumably #119146) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I'll try to push this conversation forward by nominating for T-lang discussion, keeping in mind some raised concerns. @rustbot label I-lang-nominated |
|
I'm going through PRs we've been sitting on awhile. This one ended up toward the bottom of our queue on lang for essentially the reasons @petrochenkov outlined. It's a breaking change, and those always take more work, and this one has limited upside. On top of that, it reintroduces the oddity that the reservation is partial, as noted by @petrochenkov back in 2019, as this still works: macro_rules! foo { () => (0) }
use foo as macro_rules;
fn main() {
println!("{}", macro_rules!());
}According to the Reference (here), NON_KEYWORD_IDENTIFIER -> IDENTIFIER_OR_KEYWORD _except a strict or reserved keyword_and For this proposal to have a chance, in my view, it'd need to come with documentation updates, a crater run, and a good explanation about why #62258 was done with enthusiasm and why we should feel comfortable in undoing it. Probably too, if it were to do this reservation, it should do it fully. Given the objection from @petrochenkov and the limited upside here, I just estimate that it's rather unlikely we'd do this on the basis of what's in this PR now, so while we all always want to make our diagnostics better, and I appreciate the PR author for putting in the work here, rather than leave this sit longer, I'm just going to close it out. cc @rust-lang/lang |
This PR implements better error handling around identifiers in MBEs.
It is related to #118295 which is already closed, but it fixes up issues left present by the solution for that issue.
Improved errors:
Parenthesised Ident
Previously with the code:
The compiler would output the following, incorrect error:
Now it outputs:
Missing Ident
Previously with the code:
The compiler would output the following, incorrect error:
Now it outputs:
This will interfere with the
stderrof the test case I introduced in #118928 that has not yet been merged, due to that test case requiring a (templated) parenthesised ident to be present.It includes regression tests.
🖤