Skip to content

Commit 5f99ebe

Browse files
authored
Merge pull request #2518 from topecongiro/issue-2491
Disallow combining parens and brackets in impl
2 parents 1780d68 + 10e37fd commit 5f99ebe

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

src/items.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use types::join_bounds;
3333
use utils::{colon_spaces, contains_skip, first_line_width, format_abi, format_constness,
3434
format_defaultness, format_mutability, format_unsafety, format_visibility,
3535
is_attributes_extendable, last_line_contains_single_line_comment,
36-
last_line_extendable, last_line_used_width, last_line_width, mk_sp,
37-
semicolon_for_expr, starts_with_newline, stmt_expr, trimmed_last_line_width};
36+
last_line_used_width, last_line_width, mk_sp, semicolon_for_expr, starts_with_newline,
37+
stmt_expr, trimmed_last_line_width};
3838
use vertical::rewrite_with_alignment;
3939
use visitor::FmtVisitor;
4040

@@ -631,8 +631,7 @@ pub fn format_impl(
631631
}
632632
result.push_str(&where_clause_str);
633633

634-
let need_newline = !last_line_extendable(&result)
635-
&& (last_line_contains_single_line_comment(&result) || result.contains('\n'));
634+
let need_newline = last_line_contains_single_line_comment(&result) || result.contains('\n');
636635
match context.config.brace_style() {
637636
_ if need_newline => result.push_str(&sep),
638637
BraceStyle::AlwaysNextLine => result.push_str(&sep),

tests/source/impls.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,8 @@ impl Foo {
152152
1
153153
}
154154
}
155+
156+
// #2491
157+
impl<'a, 'b, 'c> SomeThing<Something> for (&'a mut SomethingLong, &'b mut SomethingLong, &'c mut SomethingLong) {
158+
fn foo() {}
159+
}

tests/target/big-impl-block.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ impl<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyL
5252
ExcessivelyLongGenericName,
5353
ExcessivelyLongGenericName,
5454
AnotherExcessivelyLongGenericName,
55-
> {
55+
>
56+
{
5657
fn foo() {}
5758
}
5859
impl Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName>
5960
for Bar<
6061
ExcessivelyLongGenericName,
6162
ExcessivelyLongGenericName,
6263
AnotherExcessivelyLongGenericName,
63-
> {
64+
>
65+
{
6466
fn foo() {}
6567
}
6668
impl<
@@ -72,7 +74,8 @@ impl<
7274
ExcessivelyLongGenericName,
7375
ExcessivelyLongGenericName,
7476
AnotherExcessivelyLongGenericName,
75-
> {
77+
>
78+
{
7679
fn foo() {}
7780
}
7881

tests/target/impls.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,14 @@ impl Foo {
217217
1
218218
}
219219
}
220+
221+
// #2491
222+
impl<'a, 'b, 'c> SomeThing<Something>
223+
for (
224+
&'a mut SomethingLong,
225+
&'b mut SomethingLong,
226+
&'c mut SomethingLong,
227+
)
228+
{
229+
fn foo() {}
230+
}

0 commit comments

Comments
 (0)