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

Commit 0732cd6

Browse files
authored
Merge pull request rust-lang#3462 from stjepang/fix-async-formatting
Fix formatting of async blocks
2 parents 393d721 + 1fa06ec commit 0732cd6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ pub fn can_be_overflowed_expr(
13571357
}
13581358

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

13621362
// Handle `[]` and `{}`-like expressions
13631363
ast::ExprKind::Array(..) | ast::ExprKind::Struct(..) => {

tests/source/async_block.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,20 @@ fn baz() {
1616
let y = async {
1717
Ok(())
1818
}; // comment
19+
20+
spawn(
21+
a,
22+
async move {
23+
action();
24+
Ok(())
25+
},
26+
);
27+
28+
spawn(
29+
a,
30+
async move || {
31+
action();
32+
Ok(())
33+
},
34+
);
1935
}

tests/target/async_block.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@ fn baz() {
1212
};
1313

1414
let y = async { Ok(()) }; // comment
15+
16+
spawn(a, async move {
17+
action();
18+
Ok(())
19+
});
20+
21+
spawn(a, async move || {
22+
action();
23+
Ok(())
24+
});
1525
}

0 commit comments

Comments
 (0)