File tree 2 files changed +7
-0
lines changed
compiler/rustc_middle/src/mir 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -821,6 +821,11 @@ pub enum TerminatorKind<'tcx> {
821
821
/// continues at the `resume` basic block, with the second argument written to the `resume_arg`
822
822
/// place. If the coroutine is dropped before then, the `drop` basic block is invoked.
823
823
///
824
+ /// Note that coroutines can be (unstably) cloned under certain conditions, which means that
825
+ /// this terminator can **return multiple times**! MIR optimizations that reorder code into
826
+ /// different basic blocks needs to be aware of that.
827
+ /// See <https://github.com/rust-lang/rust/issues/95360>.
828
+ ///
824
829
/// Not permitted in bodies that are not coroutine bodies, or after coroutine lowering.
825
830
///
826
831
/// **Needs clarification**: What about the evaluation order of the `resume_arg` and `value`?
Original file line number Diff line number Diff line change 1
1
//@compile-flags: --diagnostic-width=300
2
2
// gate-test-coroutine_clone
3
3
// Verifies that static coroutines cannot be cloned/copied.
4
+ // This is important: the cloned coroutine would reference state of the original
5
+ // coroutine, leading to semantic nonsense.
4
6
5
7
#![ feature( coroutines, coroutine_clone, stmt_expr_attributes) ]
6
8
You can’t perform that action at this time.
0 commit comments