diff --git a/src/items.rs b/src/items.rs index e0912828f2d..e21035e615f 100644 --- a/src/items.rs +++ b/src/items.rs @@ -191,6 +191,7 @@ fn format_foreign_item(&mut self, item: &ast::ForeignItem) { &item.vis, span, false, + false, false); match rewrite { @@ -258,7 +259,8 @@ pub fn rewrite_fn(&mut self, vis, span, newline_brace, - has_body)); + has_body, + true)); if self.config.fn_brace_style != BraceStyle::AlwaysNextLine && !result.contains('\n') { newline_brace = false; @@ -303,6 +305,7 @@ pub fn rewrite_required_fn(&mut self, &ast::Visibility::Inherited, span, false, + false, false)); // Re-attach semicolon @@ -1455,7 +1458,8 @@ fn rewrite_fn_base(context: &RewriteContext, vis: &ast::Visibility, span: Span, newline_brace: bool, - has_body: bool) + has_body: bool, + has_braces: bool) -> Option<(String, bool)> { 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()); 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))); if let Some(where_clause_str) = rewrite_where_clause(context, @@ -1674,7 +1677,7 @@ fn rewrite_fn_base(context: &RewriteContext, Shape::legacy(budget, indent), Density::Compressed, "{", - !has_body, + !has_braces, put_args_in_block && ret_str.is_empty(), Some(span.hi)) { if !where_clause_str.contains('\n') { @@ -1696,7 +1699,7 @@ fn rewrite_fn_base(context: &RewriteContext, Shape::legacy(budget, indent), Density::Tall, "{", - !has_body, + !has_braces, put_args_in_block && ret_str.is_empty(), Some(span.hi))); diff --git a/tests/target/where-clause-rfc.rs b/tests/target/where-clause-rfc.rs index ff63241f8c7..6859690fa15 100644 --- a/tests/target/where-clause-rfc.rs +++ b/tests/target/where-clause-rfc.rs @@ -78,7 +78,7 @@ fn exactly_100_chars1(self, f: F) -> MyVeryLongReturnType fn very_long_function_name(very_long_argument: F) -> MyVeryLongReturnType where - F: FnMut(Self::Item) -> bool + F: FnMut(Self::Item) -> bool, { }