Trailing comma for functions with empty bodies
This commit is contained in:
parent
4df405a768
commit
ed10bf9532
13
src/items.rs
13
src/items.rs
@ -191,6 +191,7 @@ fn format_foreign_item(&mut self, item: &ast::ForeignItem) {
|
|||||||
&item.vis,
|
&item.vis,
|
||||||
span,
|
span,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
match rewrite {
|
match rewrite {
|
||||||
@ -258,7 +259,8 @@ pub fn rewrite_fn(&mut self,
|
|||||||
vis,
|
vis,
|
||||||
span,
|
span,
|
||||||
newline_brace,
|
newline_brace,
|
||||||
has_body));
|
has_body,
|
||||||
|
true));
|
||||||
|
|
||||||
if self.config.fn_brace_style != BraceStyle::AlwaysNextLine && !result.contains('\n') {
|
if self.config.fn_brace_style != BraceStyle::AlwaysNextLine && !result.contains('\n') {
|
||||||
newline_brace = false;
|
newline_brace = false;
|
||||||
@ -303,6 +305,7 @@ pub fn rewrite_required_fn(&mut self,
|
|||||||
&ast::Visibility::Inherited,
|
&ast::Visibility::Inherited,
|
||||||
span,
|
span,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
false));
|
false));
|
||||||
|
|
||||||
// Re-attach semicolon
|
// Re-attach semicolon
|
||||||
@ -1455,7 +1458,8 @@ fn rewrite_fn_base(context: &RewriteContext,
|
|||||||
vis: &ast::Visibility,
|
vis: &ast::Visibility,
|
||||||
span: Span,
|
span: Span,
|
||||||
newline_brace: bool,
|
newline_brace: bool,
|
||||||
has_body: bool)
|
has_body: bool,
|
||||||
|
has_braces: bool)
|
||||||
-> Option<(String, bool)> {
|
-> Option<(String, bool)> {
|
||||||
let mut force_new_line_for_brace = false;
|
let mut force_new_line_for_brace = false;
|
||||||
|
|
||||||
@ -1665,7 +1669,6 @@ fn rewrite_fn_base(context: &RewriteContext,
|
|||||||
} || (put_args_in_block && ret_str.is_empty());
|
} || (put_args_in_block && ret_str.is_empty());
|
||||||
|
|
||||||
if where_clause.predicates.len() == 1 && should_compress_where {
|
if where_clause.predicates.len() == 1 && should_compress_where {
|
||||||
// TODO hitting this path, but using a newline
|
|
||||||
let budget = try_opt!(context.config.max_width.checked_sub(last_line_width(&result)));
|
let budget = try_opt!(context.config.max_width.checked_sub(last_line_width(&result)));
|
||||||
if let Some(where_clause_str) =
|
if let Some(where_clause_str) =
|
||||||
rewrite_where_clause(context,
|
rewrite_where_clause(context,
|
||||||
@ -1674,7 +1677,7 @@ fn rewrite_fn_base(context: &RewriteContext,
|
|||||||
Shape::legacy(budget, indent),
|
Shape::legacy(budget, indent),
|
||||||
Density::Compressed,
|
Density::Compressed,
|
||||||
"{",
|
"{",
|
||||||
!has_body,
|
!has_braces,
|
||||||
put_args_in_block && ret_str.is_empty(),
|
put_args_in_block && ret_str.is_empty(),
|
||||||
Some(span.hi)) {
|
Some(span.hi)) {
|
||||||
if !where_clause_str.contains('\n') {
|
if !where_clause_str.contains('\n') {
|
||||||
@ -1696,7 +1699,7 @@ fn rewrite_fn_base(context: &RewriteContext,
|
|||||||
Shape::legacy(budget, indent),
|
Shape::legacy(budget, indent),
|
||||||
Density::Tall,
|
Density::Tall,
|
||||||
"{",
|
"{",
|
||||||
!has_body,
|
!has_braces,
|
||||||
put_args_in_block && ret_str.is_empty(),
|
put_args_in_block && ret_str.is_empty(),
|
||||||
Some(span.hi)));
|
Some(span.hi)));
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ fn exactly_100_chars1<F>(self, f: F) -> MyVeryLongReturnType
|
|||||||
|
|
||||||
fn very_long_function_name<F>(very_long_argument: F) -> MyVeryLongReturnType
|
fn very_long_function_name<F>(very_long_argument: F) -> MyVeryLongReturnType
|
||||||
where
|
where
|
||||||
F: FnMut(Self::Item) -> bool
|
F: FnMut(Self::Item) -> bool,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user