Skip to content

Commit

Permalink
add version date and review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
IVIURRAY committed Jan 5, 2024
1 parent a4a18d3 commit c96ad5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
10 changes: 9 additions & 1 deletion src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl<'a> FmtVisitor<'a> {
items = itemize_list_with(0);
}

let shape = self.shape();
let shape = self.shape().sub_width(2)?;
let fmt = ListFormatting::new(shape, self.config)
.trailing_separator(self.config.trailing_comma())
.preserve_newline(true);
Expand Down Expand Up @@ -658,6 +658,14 @@ impl<'a> FmtVisitor<'a> {
let context = self.get_context();
let shape = self.shape();
let attrs_str = field.attrs.rewrite(&context, shape)?;
let attrs_str = if context.config.version() == Version::Two {
field.attrs.rewrite(&context, shape)?
} else {
// Version::One formatting that was off by 1. See issue #5801
field.attrs.rewrite(&context, shape.sub_width(1)?)?
};
// sub_width(1) to take the trailing comma into account
let shape = shape.sub_width(1)?;
let lo = field
.attrs
.last()
Expand Down
16 changes: 0 additions & 16 deletions tests/source/configs/comment_width/5801.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/target/configs/comment_width/5801.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// rustfmt-comment_width: 120
// rustfmt-wrap_comments: true
// rustfmt-unstable_features: true
// rustfmt-max_width: 120
// rustfmt-version: Two

/// This function is 120 columns wide and is left alone. This comment is 120 columns wide and the formatter is also fine
fn my_super_cool_function_name(my_very_cool_argument_name: String, my_other_very_cool_argument_name: String) -> String {
Expand Down

0 comments on commit c96ad5f

Please sign in to comment.