]> git.lizzy.rs Git - rust.git/commitdiff
Fix #1259 (#1263)
authorsinkuu <sinkuu@users.noreply.github.com>
Tue, 3 Jan 2017 20:20:02 +0000 (05:20 +0900)
committerNick Cameron <nrc@ncameron.org>
Tue, 3 Jan 2017 20:20:02 +0000 (09:20 +1300)
* Use `Indent::block_indent` instead of adding `config.tab_spaces`

* Fix #1259 impl block closing brace placement

src/items.rs
tests/source/impls.rs
tests/target/impls.rs

index 665704ea20fce3138429da99cc79eab2634882f8..dafb709500281db6f088e441d861acfe90bd20ad 100644 (file)
@@ -539,6 +539,7 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) -
 
         if result.chars().last().unwrap() == '{' {
             result.push('\n');
+            result.push_str(&offset.to_string(context.config));
         }
         result.push('}');
 
@@ -698,8 +699,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
         if offset.width() + last_line_width(&result) + trait_bound_str.len() >
            context.config.ideal_width {
             result.push('\n');
-            let width = context.block_indent.width() + context.config.tab_spaces;
-            let trait_indent = Indent::new(0, width);
+            let trait_indent = context.block_indent.block_indent(context.config);
             result.push_str(&trait_indent.to_string(context.config));
         }
         result.push_str(&trait_bound_str);
index 6d65b8b4a7ad6c1d88e73ab309dbaff90039f530..978ac8cc313f3cae140ac5de1a4d1ef4034b9414 100644 (file)
@@ -103,3 +103,11 @@ impl<BorrowType, K, V, NodeType, HandleType> Handle<NodeRef<BorrowType, K, V, No
 
 impl<BorrowType, K, V, NodeType, HandleType> PartialEq for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType> {
 }
+
+mod x {
+    impl<A, B, C, D> Foo
+        where A: 'static,
+              B: 'static,
+              C: 'static,
+              D: 'static { }
+}
index 87791d25648a6c82aad33536815becfb3531d5b2..dee683d18b1d3f6c5a19ef904d493ad92fd8cfe2 100644 (file)
@@ -132,3 +132,13 @@ impl<BorrowType, K, V, NodeType, HandleType> Handle<NodeRef<BorrowType, K, V, No
 impl<BorrowType, K, V, NodeType, HandleType> PartialEq
     for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType> {
 }
+
+mod x {
+    impl<A, B, C, D> Foo
+        where A: 'static,
+              B: 'static,
+              C: 'static,
+              D: 'static
+    {
+    }
+}