Skip to content

Commit

Permalink
Remove newlines in where clauses for v2
Browse files Browse the repository at this point in the history
Fixes #5655.
  • Loading branch information
kevinji committed Jul 30, 2023
1 parent cdfa2f8 commit 1f0a773
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2998,10 +2998,12 @@ fn rewrite_bounds_on_where_clause(
DefinitiveListTactic::Vertical
};

let preserve_newline = context.config.version() == Version::One;

let fmt = ListFormatting::new(shape, context.config)
.tactic(shape_tactic)
.trailing_separator(comma_tactic)
.preserve_newline(true);
.preserve_newline(preserve_newline);
write_list(&items.collect::<Vec<_>>(), &fmt)
}

Expand Down
9 changes: 9 additions & 0 deletions tests/source/issue-5655/one.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rustfmt-version: One

fn foo<T>(_: T)
where
T: std::fmt::Debug,

T: std::fmt::Display,
{
}
9 changes: 9 additions & 0 deletions tests/source/issue-5655/two.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rustfmt-version: Two

fn foo<T>(_: T)
where
T: std::fmt::Debug,

T: std::fmt::Display,
{
}
9 changes: 9 additions & 0 deletions tests/target/issue-5655/one.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rustfmt-version: One

fn foo<T>(_: T)
where
T: std::fmt::Debug,

T: std::fmt::Display,
{
}
8 changes: 8 additions & 0 deletions tests/target/issue-5655/two.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// rustfmt-version: Two

fn foo<T>(_: T)
where
T: std::fmt::Debug,
T: std::fmt::Display,
{
}

0 comments on commit 1f0a773

Please sign in to comment.