Skip to content

Commit

Permalink
Fix formatting of async blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Stjepan Glavina committed Mar 20, 2019
1 parent 393d721 commit 1fa06ec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ pub fn can_be_overflowed_expr(
}

// Handle always block-like expressions
ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,
ast::ExprKind::Async(..) | ast::ExprKind::Block(..) | ast::ExprKind::Closure(..) => true,

// Handle `[]` and `{}`-like expressions
ast::ExprKind::Array(..) | ast::ExprKind::Struct(..) => {
Expand Down
16 changes: 16 additions & 0 deletions tests/source/async_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ fn baz() {
let y = async {
Ok(())
}; // comment

spawn(
a,
async move {
action();
Ok(())
},
);

spawn(
a,
async move || {
action();
Ok(())
},
);
}
10 changes: 10 additions & 0 deletions tests/target/async_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ fn baz() {
};

let y = async { Ok(()) }; // comment

spawn(a, async move {
action();
Ok(())
});

spawn(a, async move || {
action();
Ok(())
});
}

0 comments on commit 1fa06ec

Please sign in to comment.