mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 01:05:39 +03:00
Fix brace indentation for impl items (#927)
This commit is contained in:
+5
-3
@@ -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(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,3 +87,13 @@ fn foo() { "hi" }
|
||||
}
|
||||
|
||||
pub impl<T, Z> Foo for Bar<T, Z> where T: Foo, Z: Baz {}
|
||||
|
||||
mod m {
|
||||
impl<T> PartialEq for S<T> where T: PartialEq {
|
||||
fn eq(&self, other: &Self) {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PartialEq for S<T> where T: PartialEq { }
|
||||
}
|
||||
|
||||
@@ -112,3 +112,15 @@ pub impl<T, Z> Foo for Bar<T, Z>
|
||||
Z: Baz
|
||||
{
|
||||
}
|
||||
|
||||
mod m {
|
||||
impl<T> PartialEq for S<T>
|
||||
where T: PartialEq
|
||||
{
|
||||
fn eq(&self, other: &Self) {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PartialEq for S<T> where T: PartialEq {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user