-
Notifications
You must be signed in to change notification settings - Fork 898
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
"left behind trailing whitespace" internal error if second consecutive line comment starts with certain characters #5391
Comments
Thanks for the report! I quickly took a look at this. At least in the case that you've described above it looks like we need fn main() {
let x = 0; // X
//.Y
} At least in the case where the comment is the last item in a block we hit the following code path: Lines 311 to 325 in 3de1a09
I think the issue here is that we push an indented newline on Line 315 with the intention that the next thing we push will be the comment, but Lines 385 to 408 in 3de1a09
Still need to do some digging into the case where the comment isn't the last statement in the block, but I'd assume that something similar is happening. Also a little confused that the content of the 2nd comment would influence this, but I'll see if I can figure that out as well. |
Okay after some more digging its seems like the Lines 41 to 50 in 3de1a09
Placing a space between the leading @calebcartwright I'm wondering if you recall what I think I have a fix for this, but I wanted to get some more context on |
No. |
Got it, just wanted to see. It looks like the |
Add rustfmt::skip to some files Extracted from #2097. Five of the files being skipped here are because rustfmt is buggy (rust-lang/rustfmt#5391; see the error messages below). The other two have clearly preferable manual formatting. ```console error[internal]: left behind trailing whitespace --> tests/fail/validity/transmute_through_ptr.rs:18:18:1 | 18 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/stacked_borrows/illegal_read2.rs:10:10:1 | 10 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/stacked_borrows/illegal_read5.rs:15:15:1 | 15 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/stacked_borrows/illegal_read1.rs:10:10:1 | 10 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> /git/miri/tests/fail/erroneous_const2.rs:9:9:1 | 9 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. ```
Rustfmt fails to format the following file.
// Y
or//Y
does not hit this bug.//.Y
or//~Y
or//^Y
do.Repro against current master (3de1a09):
I looked through all the open issues matching a "left behind trailing whitespace" search in this repo (of which there are many) and all the closed ones that mention "comment" in the title, and I did not find one that matches this situation. They mostly seemed to involve comments placed in weird places inside an expression or statement, like
let x =⏎// comment⏎value;
ormap(|_|⏎//comment⏎value)
. In contrast, this issue involves comments in a location where a conscientious person might reasonably put a comment (particularly if there is more stuff in the block after the second comment, as mentioned above). In fact the compiletest_rs crate requires such comments (//~^ ERROR
) which is how Miri's test suite ran into this bug.The text was updated successfully, but these errors were encountered: