Skip to content

Commit 6a861fb

Browse files
authored
Pick up comments before where clause in traits (#4213)
1 parent e254753 commit 6a861fb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: rustfmt-core/rustfmt-lib/src/formatting/items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ pub(crate) fn format_trait(
11261126

11271127
let where_budget = context.budget(last_line_width(&result));
11281128
let pos_before_where = if generic_bounds.is_empty() {
1129-
generics.where_clause.span.lo()
1129+
generics.span.hi()
11301130
} else {
11311131
generic_bounds[generic_bounds.len() - 1].span().hi()
11321132
};

Diff for: rustfmt-core/rustfmt-lib/tests/target/issue-4211.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait SomeTrait<T>
2+
// comment
3+
where
4+
T: Copy,
5+
{
6+
}
7+
8+
trait SomeTrait
9+
// comment
10+
where
11+
T: Copy,
12+
{
13+
}

0 commit comments

Comments
 (0)