about summary refs log tree commit diff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-12-22 03:49:44 +0100
committerGitHub <noreply@github.com>2024-12-22 03:49:44 +0100
commit239b7e83371fa0a5ee95ea944ea2ac6ac1fa7395 (patch)
tree3a1362395ad90e8eba491425901eefaad7fed83a /compiler/rustc_middle
parent7cf91567c4adaa906987c9dae39a96347da7b187 (diff)
parent8f9fede0b877966a702c1f1ac6e4ade7028aef8a (diff)
Rollup merge of #134618 - RalfJung:coroutine-clone-comments, r=lqd
coroutine_clone: add comments

I was very surprised to learn that coroutines can be cloned. This has non-trivial semantic consequences that I do not think have been considered. Lucky enough, it's still unstable. Let's add some comments and pointers so we hopefully become aware when a MIR opt actually is in conflict with this.

Cc `@rust-lang/wg-mir-opt`
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/src/mir/syntax.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs
index b7ece5ffa62..0c17a2e0fe5 100644
--- a/compiler/rustc_middle/src/mir/syntax.rs
+++ b/compiler/rustc_middle/src/mir/syntax.rs
@@ -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`?