Skip to content

Commit

Permalink
Makes brace behavior consistent with empty bodies for traits and impls
Browse files Browse the repository at this point in the history
Adds a newline before the last brace on impls without a body if the first brace is also on a newline
  • Loading branch information
andrehjr committed Sep 26, 2018
1 parent ac6871f commit 2727d41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/items.rs
Expand Up @@ -755,11 +755,10 @@ pub fn format_impl(
result.push_str(&inner_indent_str);
result.push_str(visitor.buffer.to_string().trim());
result.push_str(&outer_indent_str);
}

if result.ends_with('{') && !context.config.empty_item_single_line() {
} else if need_newline || !context.config.empty_item_single_line() {
result.push_str(&sep);
}

result.push('}');

Some(result)
Expand Down
3 changes: 2 additions & 1 deletion tests/target/big-impl-block.rs
Expand Up @@ -78,4 +78,5 @@ where
S: event::Stream,
F: for<'t> FnMut(transform::Api<'t, Stream<ContentStream<S>>>) -> transform::Api<'t, X>,
X: event::Stream,
{}
{
}
12 changes: 8 additions & 4 deletions tests/target/impls.rs
Expand Up @@ -134,11 +134,13 @@ mod m {

impl<BorrowType, K, V, NodeType, HandleType>
Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
{}
{
}

impl<BorrowType, K, V, NodeType, HandleType> PartialEq
for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
{}
{
}

mod x {
impl<A, B, C, D> Foo
Expand All @@ -147,7 +149,8 @@ mod x {
B: 'static,
C: 'static,
D: 'static,
{}
{
}
}

impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo>
Expand Down Expand Up @@ -229,4 +232,5 @@ impl<'seq1, 'seq2, 'body, 'scope, Channel>
>
where
Channel: DmaChannel,
{}
{
}

0 comments on commit 2727d41

Please sign in to comment.