1
Fork 0

Add hir::GeneratorKind::Gen

This commit is contained in:
Oli Scherer 2023-10-20 19:21:24 +00:00
parent a61cf673cd
commit 14423080f1
12 changed files with 99 additions and 22 deletions

View file

@ -1513,6 +1513,9 @@ pub enum CoroutineKind {
/// An explicit `async` block or the body of an async function.
Async(CoroutineSource),
/// An explicit `gen` block or the body of a `gen` function.
Gen(CoroutineSource),
/// A coroutine literal created via a `yield` inside a closure.
Coroutine,
}
@ -1529,6 +1532,14 @@ impl fmt::Display for CoroutineKind {
k.fmt(f)
}
CoroutineKind::Coroutine => f.write_str("coroutine"),
CoroutineKind::Gen(k) => {
if f.alternate() {
f.write_str("`gen` ")?;
} else {
f.write_str("gen ")?
}
k.fmt(f)
}
}
}
}
@ -2242,6 +2253,7 @@ impl From<CoroutineKind> for YieldSource {
// Guess based on the kind of the current coroutine.
CoroutineKind::Coroutine => Self::Yield,
CoroutineKind::Async(_) => Self::Await { expr: None },
CoroutineKind::Gen(_) => Self::Yield,
}
}
}