Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 731f155

Browse files
committed
Do not add block around async closure (rust-lang#3946)
1 parent e47aae7 commit 731f155

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/closures.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ fn rewrite_closure_expr(
170170
fn allow_multi_line(expr: &ast::Expr) -> bool {
171171
match expr.kind {
172172
ast::ExprKind::Match(..)
173+
| ast::ExprKind::Async(..)
173174
| ast::ExprKind::Block(..)
174175
| ast::ExprKind::TryBlock(..)
175176
| ast::ExprKind::Loop(..)

tests/target/async_closure.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ fn main() {
1515
let x = 3;
1616
x
1717
};
18+
19+
let f = |x| async {
20+
println!("hello, world");
21+
};
1822
}

0 commit comments

Comments
 (0)