Merge pull request #1644 from topecongiro/issue-1643

Force brace on new line if the signature ends with comment
This commit is contained in:
Nick Cameron 2017-06-12 10:35:39 +12:00 committed by GitHub
commit 53e29dfe9a
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
{
}