Skip to content

Commit 940eaa1

Browse files
committed
fix(rustfmt): fix struct field formatting with doc comments present
Fixes rust-lang#5215
1 parent 368a9b7 commit 940eaa1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ pub(crate) fn rewrite_struct_field(
17091709
let mut spacing = String::from(if field.ident.is_some() {
17101710
type_annotation_spacing.1
17111711
} else {
1712-
""
1712+
" "
17131713
});
17141714
// Try to put everything on a single line.
17151715
let attr_prefix = combine_strs_with_missing_comments(
@@ -1733,7 +1733,7 @@ pub(crate) fn rewrite_struct_field(
17331733
.offset_left(overhead + spacing.len())
17341734
.and_then(|ty_shape| field.ty.rewrite(context, ty_shape));
17351735
if let Some(ref ty) = orig_ty {
1736-
if !ty.contains('\n') {
1736+
if !ty.contains('\n') && contains_comment(ty) {
17371737
return Some(attr_prefix + &spacing + ty);
17381738
}
17391739
}

0 commit comments

Comments
 (0)