From b2d3daccfa882185cc5565ca82861babc1f64dd2 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Thu, 8 Mar 2018 19:08:32 +0900 Subject: [PATCH 1/3] Add a test for #2491 --- tests/source/impls.rs | 5 +++++ tests/target/impls.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/source/impls.rs b/tests/source/impls.rs index ca8e486646a..85e0ef0d42b 100644 --- a/tests/source/impls.rs +++ b/tests/source/impls.rs @@ -152,3 +152,8 @@ impl Foo { 1 } } + +// #2491 +impl<'a, 'b, 'c> SomeThing for (&'a mut SomethingLong, &'b mut SomethingLong, &'c mut SomethingLong) { + fn foo() {} +} diff --git a/tests/target/impls.rs b/tests/target/impls.rs index 91172b39fe5..0bc28acf7ea 100644 --- a/tests/target/impls.rs +++ b/tests/target/impls.rs @@ -217,3 +217,14 @@ impl Foo { 1 } } + +// #2491 +impl<'a, 'b, 'c> SomeThing + for ( + &'a mut SomethingLong, + &'b mut SomethingLong, + &'c mut SomethingLong, + ) +{ + fn foo() {} +} From 71ca21fc23ee0c2ea52d5440dca758bf1344b476 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Thu, 8 Mar 2018 19:08:38 +0900 Subject: [PATCH 2/3] Disallow combining parens and brackets in impl --- src/items.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/items.rs b/src/items.rs index ce1bc1ae318..3793ae36577 100644 --- a/src/items.rs +++ b/src/items.rs @@ -33,8 +33,8 @@ use types::join_bounds; use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_constness, format_defaultness, format_mutability, format_unsafety, format_visibility, is_attributes_extendable, last_line_contains_single_line_comment, - last_line_extendable, last_line_used_width, last_line_width, mk_sp, - semicolon_for_expr, starts_with_newline, stmt_expr, trimmed_last_line_width}; + last_line_used_width, last_line_width, mk_sp, semicolon_for_expr, starts_with_newline, + stmt_expr, trimmed_last_line_width}; use vertical::rewrite_with_alignment; use visitor::FmtVisitor; @@ -631,8 +631,7 @@ pub fn format_impl( } result.push_str(&where_clause_str); - let need_newline = !last_line_extendable(&result) - && (last_line_contains_single_line_comment(&result) || result.contains('\n')); + let need_newline = last_line_contains_single_line_comment(&result) || result.contains('\n'); match context.config.brace_style() { _ if need_newline => result.push_str(&sep), BraceStyle::AlwaysNextLine => result.push_str(&sep), From 10e37fd42e98dd94a49f696a065b55e9abbda574 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Thu, 8 Mar 2018 19:08:56 +0900 Subject: [PATCH 3/3] Update tests --- tests/target/big-impl-block.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/target/big-impl-block.rs b/tests/target/big-impl-block.rs index bc16f12c9d7..3f26552e802 100644 --- a/tests/target/big-impl-block.rs +++ b/tests/target/big-impl-block.rs @@ -52,7 +52,8 @@ impl { + > +{ fn foo() {} } impl Foo @@ -60,7 +61,8 @@ impl Foo { + > +{ fn foo() {} } impl< @@ -72,7 +74,8 @@ impl< ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName, - > { + > +{ fn foo() {} }