Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify reference on async blocks #1262

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/expressions/block-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Async contexts are established by async blocks as well as the bodies of async fu

Async blocks act like a function boundary, much like closures.
Therefore, the `?` operator and `return` expressions both affect the output of the future, not the enclosing function or other context.
That is, `return <expr>` from within a closure will return the result of `<expr>` as the output of the future.
That is, `return <expr>` from within an async block will return the result of `<expr>` as the output of the future.
Similarly, if `<expr>?` propagates an error, that error is propagated as the result of the future.

Finally, the `break` and `continue` keywords cannot be used to branch out from an async block.
Expand All @@ -112,7 +112,7 @@ Therefore the following is illegal:
```rust,compile_fail
loop {
async move {
break; // This would break out of the loop.
break; // error[E0267]: `break` inside of an `async` block
}
}
```
Expand Down