about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNick Cameron <nrc@ncameron.org>2018-10-15 08:07:59 +1200
committerGitHub <noreply@github.com>2018-10-15 08:07:59 +1200
commita6ef302236dd353bd737d1196d7dc581ffc703a0 (patch)
tree2f16f39939a92bff5a0b4a99d8347e6788dacab3 /src
parent2f8c1fea72dee881b602d850422568b1f8c14d12 (diff)
parent5f5d04283ce68b514a13ae5c41ba3961549ab46f (diff)
Merge pull request #3100 from topecongiro/issue-3092
Fix poor formatting of empty trait with generic bounds
Diffstat (limited to 'src')
-rw-r--r--src/expr.rs4
-rw-r--r--src/items.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 7a6a1473060..8a5b3de7a14 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1937,7 +1937,9 @@ fn shape_from_rhs_tactic(
     rhs_tactic: RhsTactics,
 ) -> Option<Shape> {
     match rhs_tactic {
-        RhsTactics::ForceNextLineWithoutIndent => Some(shape.with_max_width(context.config)),
+        RhsTactics::ForceNextLineWithoutIndent => shape
+            .with_max_width(context.config)
+            .sub_width(shape.indent.width()),
         RhsTactics::Default => {
             Shape::indented(shape.indent.block_indent(context.config), context.config)
                 .sub_width(shape.rhs_overhead(context.config))
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('}');