Skip to content

Commit

Permalink
corotuine_clone: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 21, 2024
1 parent 54dcff1 commit 37c2861
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ pub enum TerminatorKind<'tcx> {
/// continues at the `resume` basic block, with the second argument written to the `resume_arg`
/// place. If the coroutine is dropped before then, the `drop` basic block is invoked.
///
/// Note that coroutines can be (unstably) cloned under certain conditions, which means that
/// this terminator can **return multiple times**! MIR optimizations that reorder code into
/// different basic blocks needs to be aware of that.
/// See <https://github.com/rust-lang/rust/issues/95360>.
///
/// Not permitted in bodies that are not coroutine bodies, or after coroutine lowering.
///
/// **Needs clarification**: What about the evaluation order of the `resume_arg` and `value`?
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/coroutine/clone-impl-static.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//@compile-flags: --diagnostic-width=300
// gate-test-coroutine_clone
// Verifies that static coroutines cannot be cloned/copied.
// This is important: the cloned coroutine would reference state of the original
// coroutine, leading to semantic nonsense.

#![feature(coroutines, coroutine_clone, stmt_expr_attributes)]

Expand Down

0 comments on commit 37c2861

Please sign in to comment.