about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSeiichi Uchida <seuchida@gmail.com>2018-10-14 21:43:59 +0900
committerSeiichi Uchida <seuchida@gmail.com>2018-10-14 21:47:55 +0900
commitfdfb489c48a1996076cede1bc1a417134fef57f2 (patch)
tree95fe64fab72fdf913c3402ec58c7eb9c1a4b8f51
parent476992a15d4e01071ac57cec7c8e54b36e606d46 (diff)
Add a correct indent before trait's closing brace with empty body
-rw-r--r--src/items.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/items.rs b/src/items.rs
index f74458fdaa6..1673bffbce9 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -1121,6 +1121,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
 
         let snippet = context.snippet(item.span);
         let open_pos = snippet.find_uncommented("{")? + 1;
+        let outer_indent_str = offset.block_only().to_string_with_newline(context.config);
 
         if !trait_items.is_empty() || contains_comment(&snippet[open_pos..]) {
             let mut visitor = FmtVisitor::from_context(context);
@@ -1134,13 +1135,12 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
             visitor.format_missing(item.span.hi() - BytePos(1));
 
             let inner_indent_str = visitor.block_indent.to_string_with_newline(context.config);
-            let outer_indent_str = offset.block_only().to_string_with_newline(context.config);
 
             result.push_str(&inner_indent_str);
             result.push_str(visitor.buffer.to_string().trim());
             result.push_str(&outer_indent_str);
         } else if result.contains('\n') {
-            result.push('\n');
+            result.push_str(&outer_indent_str);
         }
 
         result.push('}');