about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/instance.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-02-28 20:25:25 +0000
committerMichael Goulet <michael@errs.io>2024-03-19 16:59:24 -0400
commitf1fef64e19909487ff2640bce58ce49fcfb4b85d (patch)
tree7281d36cff4865852e3d9c6193ba6689204ab033 /compiler/rustc_middle/src/ty/instance.rs
parent05116c5c30dea6895fb65fe31b6f2dd0f1198b51 (diff)
downloadrust-f1fef64e19909487ff2640bce58ce49fcfb4b85d.tar.gz
rust-f1fef64e19909487ff2640bce58ce49fcfb4b85d.zip
Fix ABI for FnMut/Fn impls for async closures
Diffstat (limited to 'compiler/rustc_middle/src/ty/instance.rs')
-rw-r--r--compiler/rustc_middle/src/ty/instance.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs
index bbe0915baa2..18ef4ed549b 100644
--- a/compiler/rustc_middle/src/ty/instance.rs
+++ b/compiler/rustc_middle/src/ty/instance.rs
@@ -95,7 +95,15 @@ pub enum InstanceDef<'tcx> {
     /// The body generated here differs significantly from the `ClosureOnceShim`,
     /// since we need to generate a distinct coroutine type that will move the
     /// closure's upvars *out* of the closure.
-    ConstructCoroutineInClosureShim { coroutine_closure_def_id: DefId },
+    ConstructCoroutineInClosureShim {
+        coroutine_closure_def_id: DefId,
+        // Whether the generated MIR body takes the coroutine by-ref. This is
+        // because the signature of `<{async fn} as FnMut>::call_mut` is:
+        // `fn(&mut self, args: A) -> <Self as FnOnce>::Output`, that is to say
+        // that it returns the `FnOnce`-flavored coroutine but takes the closure
+        // by ref (and similarly for `Fn::call`).
+        receiver_by_ref: bool,
+    },
 
     /// `<[coroutine] as Future>::poll`, but for coroutines produced when `AsyncFnOnce`
     /// is called on a coroutine-closure whose closure kind greater than `FnOnce`, or
@@ -188,6 +196,7 @@ impl<'tcx> InstanceDef<'tcx> {
             | InstanceDef::ClosureOnceShim { call_once: def_id, track_caller: _ }
             | ty::InstanceDef::ConstructCoroutineInClosureShim {
                 coroutine_closure_def_id: def_id,
+                receiver_by_ref: _,
             }
             | ty::InstanceDef::CoroutineKindShim { coroutine_def_id: def_id }
             | InstanceDef::DropGlue(def_id, _)