Skip to content

Commit

Permalink
Merge pull request rust-lang#3462 from stjepang/fix-async-formatting
Browse files Browse the repository at this point in the history
Fix formatting of async blocks
  • Loading branch information
topecongiro authored Mar 21, 2019
2 parents 393d721 + 1fa06ec commit 0732cd6
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 0732cd6

Please sign in to comment.