-
Notifications
You must be signed in to change notification settings - Fork 925
Issue 4668 #4720
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
Issue 4668 #4720
Conversation
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.
Thanks for this! Could you please expand the set of test cases to include some other scenarios, particularly where wrap_comments
still holds the default false
value?
here's one in particular I'd like to include to cover non-wrapping within a chain :
fn f() {
async {
let x = true ;
/* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna felis, molestie ex. */
}
.boxed()
}
some other scenarios with more deeply indented/nested constructs would be good too (doesn't really matter how we get the indentations, nested items, control flow expressions, etc.)
src/formatting/comment.rs
Outdated
// needed to set the kind of the ending character on the last line | ||
prev_kind = self.kind; |
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.
Could you swap these, just to maintain the association of the inline comment with the same line?
// needed to set the kind of the ending character on the last line | |
prev_kind = self.kind; | |
prev_kind = self.kind; | |
// needed to set the kind of the ending character on the last line |
Add idempotent tests for wrapping block-style comment
I added a few test cases, but ran out of ideas ;) |
Thank you! We'll need to backport this on to the main 1.x release branches, and it will need to be version gated (since this change will permit rustfmt to format some things it was failing to format prior) if that's something you'd be interested in! |
Thank you for the review, @calebcartwright ! To back-port, I will have to fix this bug on all |
❤️ beautiful thank you!
Nope it's actually a bit simpler. Just open a PR against the current 1.x branch (which is https://github.com/rust-lang/rustfmt/tree/rustfmt-1.4.37 at the moment), and you'll most likely be able to just cherry-pick 65f41f3 directly. It's a bit of a long story, but at the moment the default ( There will be some additional changes required to the code on the 1.x branch, specifically to leverage the I imagine it'll basically be taking this: rustfmt/src/formatting/comment.rs Line 1444 in 6b415bd
and adding the additional check on the guard with something like: (_, FullCodeCharKind::Normal) if prev_kind == FullCodeCharKind::EndComment && self.config_version == Version::Two => { but you may need to get some additional context into the Feel free to open an early draft PR along the way if you have any questions! |
Opening a new PR as I accidentally deleted the forked rustfmt repo! This PR aims at resolving #4668.