Skip to content

Commit 7f3b340

Browse files
committed
Version gate changes to expr::shape_from_rhs_tactic
Although the issue described in 5321 could be considered a bug, it might also lead to breaking formatting changes. For that reason the fix is only applied when `version=Two`
1 parent e2f5af4 commit 7f3b340

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Diff for: src/expr.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2110,8 +2110,10 @@ fn shape_from_rhs_tactic(
21102110
shape: Shape,
21112111
rhs_tactic: RhsTactics,
21122112
) -> Option<Shape> {
2113+
let using_version_2 = context.config.version() == Version::Two;
2114+
let no_indent = shape.indent.width() == 0;
21132115
match rhs_tactic {
2114-
RhsTactics::ForceNextLineWithoutIndent if shape.indent.width() == 0 => shape
2116+
RhsTactics::ForceNextLineWithoutIndent if no_indent && using_version_2 => shape
21152117
.with_max_width(context.config)
21162118
.sub_width(context.config.tab_spaces()),
21172119
RhsTactics::ForceNextLineWithoutIndent => shape

Diff for: tests/source/issue_5321.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// rustfmt-version: Two
2+
13
trait AllTheOthers1: Trait3 + Trait4 + Trait5 + Trait6 + Trait7 + Trait8 + Trait9 + Trait10 + Trait11 + Trait12 + Trait14
24
{
35
}

Diff for: tests/target/issue_5321.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// rustfmt-version: Two
2+
13
trait AllTheOthers1:
24
Trait3
35
+ Trait4

0 commit comments

Comments
 (0)