diff --git a/src/items.rs b/src/items.rs index 7eddf63dd62a..cee1fc4f13e0 100644 --- a/src/items.rs +++ b/src/items.rs @@ -499,7 +499,8 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) - if try_opt!(is_impl_single_line(context, &items, &result, &where_clause_str, &item)) { result.push_str(&where_clause_str); if where_clause_str.contains('\n') { - result.push_str("\n{\n}"); + let white_space = offset.to_string(context.config); + result.push_str(&format!("\n{}{{\n{}}}", &white_space, &white_space)); } else { result.push_str(" {}"); } @@ -519,9 +520,10 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) - BraceStyle::PreferSameLine => result.push(' '), BraceStyle::SameLineWhere => { if !where_clause_str.is_empty() { - result.push('\n') + result.push('\n'); + result.push_str(&offset.to_string(context.config)); } else { - result.push(' ') + result.push(' '); } } } diff --git a/tests/source/impls.rs b/tests/source/impls.rs index e96baa91473c..0eb084018bc9 100644 --- a/tests/source/impls.rs +++ b/tests/source/impls.rs @@ -87,3 +87,13 @@ pub impl Foo for Bar where T: Foo } pub impl Foo for Bar where T: Foo, Z: Baz {} + +mod m { + impl PartialEq for S where T: PartialEq { + fn eq(&self, other: &Self) { + true + } + } + + impl PartialEq for S where T: PartialEq { } + } diff --git a/tests/target/impls.rs b/tests/target/impls.rs index c592ab6f9f92..38c972c00318 100644 --- a/tests/target/impls.rs +++ b/tests/target/impls.rs @@ -112,3 +112,15 @@ pub impl Foo for Bar Z: Baz { } + +mod m { + impl PartialEq for S + where T: PartialEq + { + fn eq(&self, other: &Self) { + true + } + } + + impl PartialEq for S where T: PartialEq {} +}