diff --git a/src/items.rs b/src/items.rs index fd4e08ed403..da5274dda83 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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::>(), &fmt) } diff --git a/tests/source/issue-5655/one.rs b/tests/source/issue-5655/one.rs new file mode 100644 index 00000000000..1758ec56f8b --- /dev/null +++ b/tests/source/issue-5655/one.rs @@ -0,0 +1,9 @@ +// rustfmt-version: One + +fn foo(_: T) +where + T: std::fmt::Debug, + + T: std::fmt::Display, +{ +} diff --git a/tests/source/issue-5655/two.rs b/tests/source/issue-5655/two.rs new file mode 100644 index 00000000000..e37ebbea8af --- /dev/null +++ b/tests/source/issue-5655/two.rs @@ -0,0 +1,9 @@ +// rustfmt-version: Two + +fn foo(_: T) +where + T: std::fmt::Debug, + + T: std::fmt::Display, +{ +} diff --git a/tests/target/issue-5655/one.rs b/tests/target/issue-5655/one.rs new file mode 100644 index 00000000000..1758ec56f8b --- /dev/null +++ b/tests/target/issue-5655/one.rs @@ -0,0 +1,9 @@ +// rustfmt-version: One + +fn foo(_: T) +where + T: std::fmt::Debug, + + T: std::fmt::Display, +{ +} diff --git a/tests/target/issue-5655/two.rs b/tests/target/issue-5655/two.rs new file mode 100644 index 00000000000..14fbc3d1321 --- /dev/null +++ b/tests/target/issue-5655/two.rs @@ -0,0 +1,8 @@ +// rustfmt-version: Two + +fn foo(_: T) +where + T: std::fmt::Debug, + T: std::fmt::Display, +{ +}