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:
parent
1cc4f0c35f
commit
6bf1382927
@ -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() {
|
||||
|
11
tests/target/indented-impl.rs
Normal file
11
tests/target/indented-impl.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// rustfmt-item_brace_style: AlwaysNextLine
|
||||
mod x {
|
||||
struct X(i8);
|
||||
|
||||
impl Y for X
|
||||
{
|
||||
fn y(self) -> () {
|
||||
println!("ok");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user