Check yield terminator's resume type in borrowck
This commit is contained in:
parent
139fb22146
commit
1d48f69d65
12 changed files with 190 additions and 36 deletions
|
@ -250,6 +250,9 @@ pub struct CoroutineInfo<'tcx> {
|
|||
/// The yield type of the function, if it is a coroutine.
|
||||
pub yield_ty: Option<Ty<'tcx>>,
|
||||
|
||||
/// The resume type of the function, if it is a coroutine.
|
||||
pub resume_ty: Option<Ty<'tcx>>,
|
||||
|
||||
/// Coroutine drop glue.
|
||||
pub coroutine_drop: Option<Body<'tcx>>,
|
||||
|
||||
|
@ -385,6 +388,7 @@ impl<'tcx> Body<'tcx> {
|
|||
coroutine: coroutine_kind.map(|coroutine_kind| {
|
||||
Box::new(CoroutineInfo {
|
||||
yield_ty: None,
|
||||
resume_ty: None,
|
||||
coroutine_drop: None,
|
||||
coroutine_layout: None,
|
||||
coroutine_kind,
|
||||
|
@ -551,6 +555,11 @@ impl<'tcx> Body<'tcx> {
|
|||
self.coroutine.as_ref().and_then(|coroutine| coroutine.yield_ty)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn resume_ty(&self) -> Option<Ty<'tcx>> {
|
||||
self.coroutine.as_ref().and_then(|coroutine| coroutine.resume_ty)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn coroutine_layout(&self) -> Option<&CoroutineLayout<'tcx>> {
|
||||
self.coroutine.as_ref().and_then(|coroutine| coroutine.coroutine_layout.as_ref())
|
||||
|
|
|
@ -996,6 +996,12 @@ macro_rules! super_body {
|
|||
TyContext::YieldTy(SourceInfo::outermost(span))
|
||||
);
|
||||
}
|
||||
if let Some(resume_ty) = $(& $mutability)? gen.resume_ty {
|
||||
$self.visit_ty(
|
||||
resume_ty,
|
||||
TyContext::ResumeTy(SourceInfo::outermost(span))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (bb, data) in basic_blocks_iter!($body, $($mutability, $invalidate)?) {
|
||||
|
@ -1244,6 +1250,8 @@ pub enum TyContext {
|
|||
|
||||
YieldTy(SourceInfo),
|
||||
|
||||
ResumeTy(SourceInfo),
|
||||
|
||||
/// A type found at some location.
|
||||
Location(Location),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue