* Use `Indent::block_indent` instead of adding `config.tab_spaces`

* Fix #1259 impl block closing brace placement
This commit is contained in:
sinkuu 2017-01-04 05:20:02 +09:00 committed by Nick Cameron
parent 90db34a961
commit 1358f1ac80
3 changed files with 20 additions and 2 deletions

View 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);

View 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 { }
}

View 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
{
}
}