Force brace on new line if the signature ends with comment

This commit is contained in:
topecongiro 2017-06-09 16:15:31 +09:00
parent c879d5ebd7
commit c92064c30a
2 changed files with 11 additions and 1 deletions

View File

@ -1871,6 +1871,7 @@ fn rewrite_fn_base(context: &RewriteContext,
result.push_str(&where_clause_str);
force_new_line_for_brace |= last_line_contains_single_line_comment(&result);
return Some((result, force_new_line_for_brace));
}
}
@ -1888,7 +1889,12 @@ fn rewrite_fn_base(context: &RewriteContext,
result.push_str(&where_clause_str);
Some((result, force_new_line_for_brace))
force_new_line_for_brace |= last_line_contains_single_line_comment(&result);
return Some((result, force_new_line_for_brace));
}
fn last_line_contains_single_line_comment(s: &str) -> bool {
s.lines().last().map_or(false, |l| l.contains("//"))
}
fn rewrite_args(context: &RewriteContext,

View File

@ -19,3 +19,7 @@ fn foo<F, G>(a: aaaaaaaaaaaaa, // A comment
fn bar<F /* comment on F */, G /* comment on G */>() {}
fn baz() -> Baz /* Comment after return type */ {}
fn some_fn<T>() where T: Eq // some comment
{
}