-
Notifications
You must be signed in to change notification settings - Fork 888
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
format_strings breaks after "\\" resulting in invalid output #5138
Comments
Note this happens when the |
This is one I'm fairly confident has been fixed on the other branch and just needs to have the commits cherry-picked over |
Was it maybe 472a2ed? |
I actually was thinking about #4524. Whenever you get a chance would you mind seeing if this behavior is reproducible on the 2.0 branch? If not that means the it's covered by that fix too, in which case we should give that another quick pass and consider backporting the commit(s) |
on the fn raw() {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
\\a";
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\";
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\";
} It's a slightly different formatting that the // This compiles
fn main() {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
\\a";
} The bad news is that the last two lines aren't formatted any differently so there's still some work to do, but I think backporting the existing changes is a good starting point. |
Thanks for digging into this!
Perhaps, though if that doesn't fully address the overall issue it may be better to try to find a holistic solution instead |
Yeah you might be right |
This incorrect output has already been fixed in version 1.60.0-nightly. In fact, the following output appears:
In this case, I don't know if the correct thing would be to increase the size or simply show the same message. Also because the case above, from a practical and functional point of view, does not seem to make sense to me. Any objection to this question @bddap ?
|
Sorry, @lobocode . Not sure I understand what you are asking. |
I'm asking if you've checked, if this bug has been fixed in later versions of rustfmt. |
I have not. |
…with escape backslash
…with escape backslash
fn main() {
let body = format!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"");
/* After cargo fmt:
let body = format!(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
""
);
*/
} Another badcase with |
rustfmt 1.4.38-nightly (efec545 2021-12-04)
installed via rustup
The text was updated successfully, but these errors were encountered: