-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Improve escaping of byte, byte str, and c str proc-macro literals #123769
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
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
This comment has been minimized.
This comment has been minimized.
|
Given the FCP here and that this is mostly an improvement / not a bug fix I'd say we should wait until it gets stabilized (on beta?) |
|
If anything, having an official non- |
|
I don't think we should add burden of maintainability to a first-party library to ease the burden of maintainability of a third-party library. |
This module contains tests not just of parse (FromStr) but also to_string (Display) for literals.
|
@rustbot ready The new implementation compiles with stable Rust 1.79, which contains the stabilization of |
fee1-dead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
|
@bors r+ |
This PR changes the behavior of
proc_macro::Literal::byte_character(#115268),byte_string, andc_string(#119750) to improve their choice of escape sequences. 3 categories of changes are made:Never use
\x00. Always prefer\0, which is supported in all the same places.Never escape
\'inside double quotes and\"inside single quotes.Never use
\xfor valid UTF-8 in literals that permit\u.The second commit adds tests covering these cases, asserting the old behavior.
The third commit implements the behavior change and simultaneously updates the tests to assert the new behavior.