Skip to content

Commit 0221eac

Browse files
committed
Draft: fix: Fn supertraits indentation
1 parent 202fa22 commit 0221eac

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/expr.rs

Lines changed: 11 additions & 1 deletion
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,6 +2141,16 @@ 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+
if let RhsAssignKind::Bounds = rhs_kind {
2145+
if new_rhs.contains("->") {
2146+
return Some(
2147+
new_rhs
2148+
.lines()
2149+
.map(|l| format!("{new_indent_str}{l}"))
2150+
.join(""),
2151+
);
2152+
}
2153+
}
21442154
Some(format!("{new_indent_str}{new_rhs}"))
21452155
}
21462156
(None, Some(ref new_rhs)) => Some(format!("{new_indent_str}{new_rhs}")),

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)