Skip to content

Commit 5cf30de

Browse files
committed
Draft: fix: Fn supertraits indentation
1 parent 202fa22 commit 5cf30de

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/expr.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ fn choose_rhs<R: Rewrite>(
21102110
expr: &R,
21112111
shape: Shape,
21122112
orig_rhs: Option<String>,
2113-
_rhs_kind: &RhsAssignKind<'_>,
2113+
rhs_kind: &RhsAssignKind<'_>,
21142114
rhs_tactics: RhsTactics,
21152115
has_rhs_comment: bool,
21162116
) -> Option<String> {
@@ -2141,7 +2141,11 @@ fn choose_rhs<R: Rewrite>(
21412141
(Some(ref orig_rhs), Some(ref new_rhs))
21422142
if prefer_next_line(orig_rhs, new_rhs, rhs_tactics) =>
21432143
{
2144-
Some(format!("{new_indent_str}{new_rhs}"))
2144+
if let RhsAssignKind::Bounds = rhs_kind {
2145+
Some(new_rhs.lines().map(|l| format!("{new_indent_str}{l}")).join(""))
2146+
} else {
2147+
Some(format!("{new_indent_str}{new_rhs}"))
2148+
}
21452149
}
21462150
(None, Some(ref new_rhs)) => Some(format!("{new_indent_str}{new_rhs}")),
21472151
(None, None) if rhs_tactics == RhsTactics::AllowOverflow => {

tests/source/issue-6127.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo:
2+
Fn(
3+
ReallyLongTypeName,
4+
ReallyLongTypeName,
5+
ReallyLongTypeName,
6+
ReallyLongTypeName,
7+
) -> ReallyLongTypeName
8+
{
9+
}

tests/target/issue-6127.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo:
2+
Fn(
3+
ReallyLongTypeName,
4+
ReallyLongTypeName,
5+
ReallyLongTypeName,
6+
ReallyLongTypeName,
7+
) -> ReallyLongTypeName
8+
{
9+
}

0 commit comments

Comments
 (0)