-
Notifications
You must be signed in to change notification settings - Fork 933
Open
Labels
1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and releaseFixed/resolved in source but not yet backported to a 1x branch and releasea-stringsString literalsString literalsbugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.help wantedonly-with-optionrequires a non-default option value to reproducerequires a non-default option value to reproduce
Description
#[rustfmt::skip]
fn raw() {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\a";
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\";
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\";
}
fn formatted() {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\
\a";
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\";
"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\";
}
rustfmt 1.4.38-nightly (efec545 2021-12-04)
installed via rustup
Metadata
Metadata
Assignees
Labels
1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and releaseFixed/resolved in source but not yet backported to a 1x branch and releasea-stringsString literalsString literalsbugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.help wantedonly-with-optionrequires a non-default option value to reproducerequires a non-default option value to reproduce
Activity
bddap commentedon Dec 14, 2021
format_strings = true
Note this happens when the
"\\"
is at a position close to max width.calebcartwright commentedon Dec 16, 2021
This is one I'm fairly confident has been fixed on the other branch and just needs to have the commits cherry-picked over
ytmimi commentedon Dec 17, 2021
Was it maybe 472a2ed?
calebcartwright commentedon Dec 21, 2021
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)
ytmimi commentedon Dec 23, 2021
on the
2.x
branch here's howrustfmt
formats the input:It's a slightly different formatting that the
1.x
branch, but it still doesn't compile. The silver lining here is that the2.x
branch formats the first line in a way that would compile if it was the only line that we needed to be reformatted.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.
calebcartwright commentedon Dec 23, 2021
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
ytmimi commentedon Dec 23, 2021
Yeah you might be right
scovl commentedon Jan 26, 2022
This incorrect output has already been fixed in version 1.60.0-nightly. In fact, the following output appears:
error[internal]: line formatted, but exceeded maximum width (maximum: 100 (see
max_widthoption), found: 103)
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 ?
bddap commentedon Jan 26, 2022
Sorry, @lobocode . Not sure I understand what you are asking.
scovl commentedon Jan 27, 2022
I'm asking if you've checked, if this bug has been fixed in later versions of rustfmt.
bddap commentedon Jan 31, 2022
I have not.
Backport rust-lang#4524 and fix rust-lang#5138 - proper wrap strings …
Backport rust-lang#4524 and fix rust-lang#5138 - proper wrap strings …
ldm0 commentedon Oct 8, 2022
Another badcase with
format_strings = true
enabled.fix rust-lang#4471 and rust-lang#5138