-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reimplement the lexing of c"…"
string literals with backward compatibility in mind
#113333
Comments
c"…"
string literals with backward compatiblity in mindc"…"
string literals with backward compatibility in mind
…=compiler-errors Revert the lexing of `c"…"` string literals Fixes \[after beta-backport\] rust-lang#113235. Further progress is tracked in rust-lang#113333. This PR *manually* reverts parts of rust-lang#108801 (since a git-revert would've been too coarse-grained & messy) and git-reverts rust-lang#111647. CC `@fee1-dead` (rust-lang#108801) `@klensy` (rust-lang#111647) r? `@compiler-errors` `@rustbot` label F-c_str_literals beta-nominated
Could c strings be added to 2021 editions+ only? |
@SUPERCILEX On paper, this sounds like a good idea, but in practice, one does not merely do that. Proc macros could use an older version while the source using it could use a newer version. In this case, the newer source code, when parsed, will yield one AST, while the proc macro may break due to those unfamiliar features. I'm not familiar enough with the compiler to know how it addresses it, so don't take that as authoritative. |
I think the plan is to only support this on 2021+ editions while treating it as an unknown prefix in 2018 or older, which would allow compatibility with macros that want As for macros across crates, I think it wouldn't be an issue? There should already be mechanisms to prevent this sort of thing from happening. We should definitely add a test case to test this behavior. |
We do already recombine some tokens in the parser (I believe Seems like it wouldn’t be terribly hard to do it for (edit: this is in response to #113235 (comment)) |
Yup, there's break_and_eat (and its various convenience methods). However, as already mentioned, every user of the lexer ( FYI, there's already a PR that would fix this issue (by mainly modifying the lexer, not the parser; at the time of this writing), namely #113476 (although it doesn't mention this issue). |
IIRC from the spec it's |
The lexing of
c"…"
string literals as implemented in #108801 had to be reverted in #113334 since it isn't backward compatible.It breaks code that uses a pre-2021 edition (i.e. the 2015 or the 2018 edition).
See #113235 (comment) for details.
@rustbot label C-bug T-compiler F-c_str_literals
The text was updated successfully, but these errors were encountered: