-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Suffixed string and char literals are accepted if they don't go through parser #60494
Comments
This is listed as an unresolved question in the RFC introducing literal suffixes into lexer (rust-lang/rfcs#463). |
@rust-lang/lang needs to make some decision and document it in the reference. |
@petrochenkov What are the advantages to Alt 1. as you see it? Also, do we have some sort of crater data? |
This is just a somewhat exceptional case of a token which is lexically valid, but always rejected by parser. After some thought, yeah, there's probably not much advantage. |
Yeah my inclination is that this may be useful for macro authors somehow so I think we can leave this accepted. |
I regret not coming up with the "joint" system for composed tokens much earlier, and doing at least literal suffixes with it. But overall, I'm in favor of as much flexibility as possible for proc macro authors. The only useful constraint I see, in terms of the token model, is having balanced (Although I don't know if other @rust-lang/lang members share this view) |
I agree with @eddyb as well =) |
Looks like there's some consensus to keep the existing behavior. |
Things like
"abc"suffix
are lexically valid tokens, but they are reported as errors when parsed with the Rust Language Parser.However, macro inputs are not parsed by the Rust Language Parser, each macro has its own language that it parses by itself.
It means that suffixed string and char literals can be passed to procedural macros (a procedural macro can process them as they want and make them legal and meaningful in its language), or declarative macros (if they are ignored).
Example:
Possible solutions:
The text was updated successfully, but these errors were encountered: