1
Fork 0

Rollup merge of #120330 - compiler-errors:no-coroutine-info-in-coroutine-drop-body, r=nnethercote

Remove coroutine info when building coroutine drop body

Coroutine drop shims are not themselves coroutines, so erase the "`coroutine`" field from the body so that helper fns like `yield_ty` and `coroutine_kind` properly return `None` for the drop shim.
This commit is contained in:
Matthias Krüger 2024-01-25 17:39:29 +01:00 committed by GitHub
commit 4bca954634
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 47 deletions

View file

@ -1231,7 +1231,12 @@ fn create_coroutine_drop_shim<'tcx>(
drop_clean: BasicBlock,
) -> Body<'tcx> {
let mut body = body.clone();
body.arg_count = 1; // make sure the resume argument is not included here
// Take the coroutine info out of the body, since the drop shim is
// not a coroutine body itself; it just has its drop built out of it.
let _ = body.coroutine.take();
// Make sure the resume argument is not included here, since we're
// building a body for `drop_in_place`.
body.arg_count = 1;
let source_info = SourceInfo::outermost(body.span);