about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-01-25 19:17:21 +0000
committerMichael Goulet <michael@errs.io>2024-02-06 02:22:58 +0000
commitc98d6994a390044410c55c45195d330e4c8cd3d7 (patch)
tree52cd52eceb02c3bbfd65cff7f227417b27a68a84 /compiler/rustc_ty_utils/src
parent37184e86ea58bc90b8cd97f877d52ccce8ea02ab (diff)
downloadrust-c98d6994a390044410c55c45195d330e4c8cd3d7.tar.gz
rust-c98d6994a390044410c55c45195d330e4c8cd3d7.zip
More comments, final tweaks
Diffstat (limited to 'compiler/rustc_ty_utils/src')
-rw-r--r--compiler/rustc_ty_utils/src/abi.rs6
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs7
2 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs
index 3ea48ee824d..e023283a709 100644
--- a/compiler/rustc_ty_utils/src/abi.rs
+++ b/compiler/rustc_ty_utils/src/abi.rs
@@ -112,6 +112,10 @@ fn fn_sig_for_fn_abi<'tcx>(
             };
             let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
 
+            // When this `CoroutineClosure` comes from a `ConstructCoroutineInClosureShim`,
+            // make sure we respect the `target_kind` in that shim.
+            // FIXME(async_closures): This shouldn't be needed, and we should be populating
+            // a separate def-id for these bodies.
             let mut kind = args.as_coroutine_closure().kind();
             if let InstanceDef::ConstructCoroutineInClosureShim { target_kind, .. } = instance.def {
                 kind = target_kind;
@@ -141,6 +145,8 @@ fn fn_sig_for_fn_abi<'tcx>(
             )
         }
         ty::Coroutine(did, args) => {
+            // FIXME(async_closures): This isn't right for `CoroutineByMoveShim`.
+
             let coroutine_kind = tcx.coroutine_kind(did).unwrap();
             let sig = args.as_coroutine().sig();
 
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index fc224d242db..9faad10dd14 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -287,6 +287,13 @@ fn resolve_associated_item<'tcx>(
             {
                 match *rcvr_args.type_at(0).kind() {
                     ty::CoroutineClosure(coroutine_closure_def_id, args) => {
+                        // If we're computing `AsyncFnOnce`/`AsyncFnMut` for a by-ref closure,
+                        // or `AsyncFnOnce` for a by-mut closure, then construct a new body that
+                        // has the right return types.
+                        //
+                        // Specifically, `AsyncFnMut` for a by-ref coroutine-closure just needs
+                        // to have its input and output types fixed (`&mut self` and returning
+                        // `i16` coroutine kind).
                         if target_kind > args.as_coroutine_closure().kind() {
                             Some(Instance {
                                 def: ty::InstanceDef::ConstructCoroutineInClosureShim {