Indent open brace for impl when nested. (#1227)

* Indent open brace for impl when nested.

Fixes #1226

* Added test case for indented impl with brace on newline
This commit is contained in:
Luke Clifton 2016-11-28 08:47:07 +08:00 committed by Nick Cameron
parent 1cc4f0c35f
commit 6bf1382927
2 changed files with 15 additions and 1 deletions

View File

@ -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() {

View File

@ -0,0 +1,11 @@
// rustfmt-item_brace_style: AlwaysNextLine
mod x {
struct X(i8);
impl Y for X
{
fn y(self) -> () {
println!("ok");
}
}
}