Skip to content

Fix/Visual IndentStyle is broken on impl with where clause #5460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ pub(crate) fn format_impl(
generics.where_clause.span,
context.config.brace_style(),
Shape::legacy(where_budget, offset.block_only()),
false,
true,
"{",
where_span_end,
self_ty.span.hi(),
Expand Down
26 changes: 26 additions & 0 deletions tests/source/issue-3071/issue-3071-where-single-line.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// rustfmt-indent_style: Visual
// rustfmt-where_single_line: true

struct A<T>
where T: Send
{
x: u32,
}

impl<T> A<T> where T: Send
{
fn foo() {}
}


struct B<T, K>
where T: Send,
K: Eq
{
y: u32,
}

impl<T,K> B<T,K> where T: Send, K: Eq
{
fn bar() {}
}
25 changes: 25 additions & 0 deletions tests/source/issue-3071/issue-3071.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// rustfmt-indent_style: Visual

struct A<T>
where T: Send
{
x: u32,
}

impl<T> A<T> where T: Send
{
fn foo() {}
}


struct B<T, K>
where T: Send,
K: Eq
{
y: u32,
}

impl<T,K> B<T,K> where T: Send, K: Eq
{
fn bar() {}
}
28 changes: 28 additions & 0 deletions tests/target/issue-3071/issue-3071-where-single-line.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// rustfmt-indent_style: Visual
// rustfmt-where_single_line: true

struct A<T>
where T: Send
{
x: u32,
}

impl<T> A<T>
where T: Send
{
fn foo() {}
}

struct B<T, K>
where T: Send,
K: Eq
{
y: u32,
}

impl<T, K> B<T, K>
where T: Send,
K: Eq
{
fn bar() {}
}
27 changes: 27 additions & 0 deletions tests/target/issue-3071/issue-3071.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// rustfmt-indent_style: Visual

struct A<T>
where T: Send
{
x: u32,
}

impl<T> A<T>
where T: Send
{
fn foo() {}
}

struct B<T, K>
where T: Send,
K: Eq
{
y: u32,
}

impl<T, K> B<T, K>
where T: Send,
K: Eq
{
fn bar() {}
}