Rollup merge of #119563 - compiler-errors:coroutine-resume, r=oli-obk

Check yield terminator's resume type in borrowck

In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops!

This PR implements this checking.

Fixes #119564

r? types
This commit is contained in:
Matthias Krüger 2024-01-05 20:39:53 +01:00 committed by GitHub
commit ad7aabd965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 190 additions and 36 deletions

View file

@ -1733,6 +1733,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
}
body.coroutine.as_mut().unwrap().yield_ty = None;
body.coroutine.as_mut().unwrap().resume_ty = None;
body.coroutine.as_mut().unwrap().coroutine_layout = Some(layout);
// Insert `drop(coroutine_struct)` which is used to drop upvars for coroutines in