-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
macros can observe raw identifier state [discuss] #49520
Comments
Thanks for creating this issue, this is an interesting case. |
My reasoning (#48942 (comment)) when merging this behavior was that identifiers on the left side of a macro are keywords in the grammar introduced by that macro (each macro introduces a new grammar and doesn't care about keywords defined by the general language), so raw identifiers provide opt-out from those keywords in the same way like they provide opt-out for the large grammar of the whole Rust language. "Raw keywords" introduced by macros ( |
One example: macro my_macro {
(struct { $i: ident }) => {}
(construct { $i: ident }) => {}
} From |
@petrochenkov yeah, that makes a lot of sense, and I'm coming around to this POV
I agree with this. This would resolve a lot of my concerns, I think. |
Wait, it feels a lot more natural to simply not care. Like you said the grammar doesn't care about keywords or any other bit of syntax: /// I should be able to do this because it's a macro
macro_rules! blank {
() => { ;}
} So this shouldn't make any difference. |
In #48942, @Lymia landed raw identifiers; "equality" in this implementation includes observing the "raw" state. Therefore, macros can observe if
r#foo
was used or not:This makes a certain measure of sense, but also makes me nervous, and I wanted to open an issue to discuss. For example, @Manishearth proposed making identifiers "raw" in macros when they are serialized, thus ensuring consistent interpretation as we cross editions.
I'm not entirely sure of the implications of this but it does make me nervous for users to be able to distinguish
foo
andr#foo
.The text was updated successfully, but these errors were encountered: