Skip to content

Commit 86fff9e

Browse files
authored
Merge pull request #3050 from andrehjr/empty-impl-body-with-braces-newline
Trait Implementation - Adds a newline before the last brace on impls without a body if the first brace is also on a newline
2 parents 333c580 + 2727d41 commit 86fff9e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/items.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,10 @@ pub fn format_impl(
755755
result.push_str(&inner_indent_str);
756756
result.push_str(visitor.buffer.to_string().trim());
757757
result.push_str(&outer_indent_str);
758-
}
759-
760-
if result.ends_with('{') && !context.config.empty_item_single_line() {
758+
} else if need_newline || !context.config.empty_item_single_line() {
761759
result.push_str(&sep);
762760
}
761+
763762
result.push('}');
764763

765764
Some(result)

tests/target/big-impl-block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ where
7878
S: event::Stream,
7979
F: for<'t> FnMut(transform::Api<'t, Stream<ContentStream<S>>>) -> transform::Api<'t, X>,
8080
X: event::Stream,
81-
{}
81+
{
82+
}

tests/target/impls.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ mod m {
134134

135135
impl<BorrowType, K, V, NodeType, HandleType>
136136
Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
137-
{}
137+
{
138+
}
138139

139140
impl<BorrowType, K, V, NodeType, HandleType> PartialEq
140141
for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
141-
{}
142+
{
143+
}
142144

143145
mod x {
144146
impl<A, B, C, D> Foo
@@ -147,7 +149,8 @@ mod x {
147149
B: 'static,
148150
C: 'static,
149151
D: 'static,
150-
{}
152+
{
153+
}
151154
}
152155

153156
impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo>
@@ -229,4 +232,5 @@ impl<'seq1, 'seq2, 'body, 'scope, Channel>
229232
>
230233
where
231234
Channel: DmaChannel,
232-
{}
235+
{
236+
}

0 commit comments

Comments
 (0)