Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fdfb489

Browse files
committed
Add a correct indent before trait's closing brace with empty body
1 parent 476992a commit fdfb489

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
11211121

11221122
let snippet = context.snippet(item.span);
11231123
let open_pos = snippet.find_uncommented("{")? + 1;
1124+
let outer_indent_str = offset.block_only().to_string_with_newline(context.config);
11241125

11251126
if !trait_items.is_empty() || contains_comment(&snippet[open_pos..]) {
11261127
let mut visitor = FmtVisitor::from_context(context);
@@ -1134,13 +1135,12 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
11341135
visitor.format_missing(item.span.hi() - BytePos(1));
11351136

11361137
let inner_indent_str = visitor.block_indent.to_string_with_newline(context.config);
1137-
let outer_indent_str = offset.block_only().to_string_with_newline(context.config);
11381138

11391139
result.push_str(&inner_indent_str);
11401140
result.push_str(visitor.buffer.to_string().trim());
11411141
result.push_str(&outer_indent_str);
11421142
} else if result.contains('\n') {
1143-
result.push('\n');
1143+
result.push_str(&outer_indent_str);
11441144
}
11451145

11461146
result.push('}');

0 commit comments

Comments
 (0)