Merge pull request #2518 from topecongiro/issue-2491

Disallow combining parens and brackets in impl
This commit is contained in:
Nick Cameron 2018-03-09 15:15:21 +13:00 committed by GitHub
commit 5f99ebe628
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 7 deletions

View File

@ -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),

View File

@ -152,3 +152,8 @@ impl Foo {
1
}
}
// #2491
impl<'a, 'b, 'c> SomeThing<Something> for (&'a mut SomethingLong, &'b mut SomethingLong, &'c mut SomethingLong) {
fn foo() {}
}

View File

@ -52,7 +52,8 @@ impl<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyL
ExcessivelyLongGenericName,
ExcessivelyLongGenericName,
AnotherExcessivelyLongGenericName,
> {
>
{
fn foo() {}
}
impl Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName>
@ -60,7 +61,8 @@ impl Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessiv
ExcessivelyLongGenericName,
ExcessivelyLongGenericName,
AnotherExcessivelyLongGenericName,
> {
>
{
fn foo() {}
}
impl<
@ -72,7 +74,8 @@ impl<
ExcessivelyLongGenericName,
ExcessivelyLongGenericName,
AnotherExcessivelyLongGenericName,
> {
>
{
fn foo() {}
}

View File

@ -217,3 +217,14 @@ impl Foo {
1
}
}
// #2491
impl<'a, 'b, 'c> SomeThing<Something>
for (
&'a mut SomethingLong,
&'b mut SomethingLong,
&'c mut SomethingLong,
)
{
fn foo() {}
}