From: sinkuu Date: Tue, 3 Jan 2017 20:20:02 +0000 (+0900) Subject: Fix #1259 (#1263) X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=1358f1ac806f10c5dbd80dd02934bf98d01993f2;p=rust.git Fix #1259 (#1263) * Use `Indent::block_indent` instead of adding `config.tab_spaces` * Fix #1259 impl block closing brace placement --- diff --git a/src/items.rs b/src/items.rs index 665704ea20f..dafb7095002 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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); diff --git a/tests/source/impls.rs b/tests/source/impls.rs index 6d65b8b4a7a..978ac8cc313 100644 --- a/tests/source/impls.rs +++ b/tests/source/impls.rs @@ -103,3 +103,11 @@ impl Handle PartialEq for Handle, HandleType> { } + +mod x { + impl Foo + where A: 'static, + B: 'static, + C: 'static, + D: 'static { } +} diff --git a/tests/target/impls.rs b/tests/target/impls.rs index 87791d25648..dee683d18b1 100644 --- a/tests/target/impls.rs +++ b/tests/target/impls.rs @@ -132,3 +132,13 @@ impl Handle PartialEq for Handle, HandleType> { } + +mod x { + impl Foo + where A: 'static, + B: 'static, + C: 'static, + D: 'static + { + } +}