diff --git a/src/items.rs b/src/items.rs index ac8a96a0fe0..3e510421976 100644 --- a/src/items.rs +++ b/src/items.rs @@ -497,7 +497,10 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) - result.push_str(&where_clause_str); match context.config.item_brace_style { - BraceStyle::AlwaysNextLine => result.push('\n'), + BraceStyle::AlwaysNextLine => { + result.push('\n'); + result.push_str(&offset.to_string(context.config)); + } BraceStyle::PreferSameLine => result.push(' '), BraceStyle::SameLineWhere => { if !where_clause_str.is_empty() { diff --git a/tests/target/indented-impl.rs b/tests/target/indented-impl.rs new file mode 100644 index 00000000000..9acab7d757e --- /dev/null +++ b/tests/target/indented-impl.rs @@ -0,0 +1,11 @@ +// rustfmt-item_brace_style: AlwaysNextLine +mod x { + struct X(i8); + + impl Y for X + { + fn y(self) -> () { + println!("ok"); + } + } +}