From 541858ed787a66bbb00a4edd21f924ed0f208a9d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 19 Mar 2024 12:55:26 -0400 Subject: Add a few more comments --- compiler/rustc_mir_transform/src/shim.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/rustc_mir_transform') diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 4b2243598dc..28b502e8cab 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -1023,7 +1023,16 @@ fn build_construct_coroutine_by_move_shim<'tcx>( bug!(); }; + // We use `*mut Self` here because we only need to emit an ABI-compatible shim body, + // rather than match the signature exactly. + // + // The self type here is a coroutine-closure, not a coroutine, and we never read from + // it because it never has any captures, because this is only true in the Fn/FnMut + // implementation, not the AsyncFn/AsyncFnMut implementation, which is implemented only + // if the coroutine-closure has no captures. if receiver_by_ref { + // Triple-check that there's no captures here. + assert_eq!(args.as_coroutine_closure().tupled_upvars_ty(), tcx.types.unit); self_ty = Ty::new_mut_ptr(tcx, self_ty); } -- cgit 1.4.1-3-g733a5