Skip to content

Commit bd0facd

Browse files
committed
only wrap on trailing comments, allow /* */ comments in-line
1 parent b2d57b9 commit bd0facd

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

rustfmt-core/src/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ pub fn format_struct_struct(
12041204
)?;
12051205

12061206
if !items_str.contains('\n') && !result.contains('\n') && items_str.len() <= one_line_budget
1207-
&& !contains_comment(&items_str)
1207+
&& !last_line_contains_single_line_comment(&items_str)
12081208
{
12091209
Some(format!("{} {} }}", result, items_str))
12101210
} else {

rustfmt-core/tests/source/issue-2446.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ enum Issue2446 {
33
f: u8, // x
44
},
55
}
6+
7+
enum Issue2446TrailingCommentsOnly {
8+
V {
9+
f: u8, /* */
10+
}
11+
}

rustfmt-core/tests/target/issue-2446.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ enum Issue2446 {
33
f: u8, // x
44
},
55
}
6+
7+
enum Issue2446TrailingCommentsOnly {
8+
V { f: u8 /* */ },
9+
}

0 commit comments

Comments
 (0)