1
Fork 0

Rename AsyncCoroutineKind to CoroutineSource

similar to how we have `MatchSource`, it explains where the desugaring came from.
This commit is contained in:
Oli Scherer 2023-10-23 17:02:40 +00:00
parent eb03d40a9c
commit af8a998b1e
19 changed files with 59 additions and 59 deletions

View file

@ -1511,7 +1511,7 @@ impl<'hir> Body<'hir> {
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum CoroutineKind {
/// An explicit `async` block or the body of an async function.
Async(AsyncCoroutineKind),
Async(CoroutineSource),
/// A coroutine literal created via a `yield` inside a closure.
Coroutine,
@ -1535,40 +1535,40 @@ impl CoroutineKind {
}
}
/// In the case of a coroutine created as part of an async construct,
/// which kind of async construct caused it to be created?
/// In the case of a coroutine created as part of an async/gen construct,
/// which kind of async/gen construct caused it to be created?
///
/// This helps error messages but is also used to drive coercions in
/// type-checking (see #60424).
#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum AsyncCoroutineKind {
/// An explicit `async` block written by the user.
pub enum CoroutineSource {
/// An explicit `async`/`gen` block written by the user.
Block,
/// An explicit `async` closure written by the user.
/// An explicit `async`/`gen` closure written by the user.
Closure,
/// The `async` block generated as the body of an async function.
/// The `async`/`gen` block generated as the body of an async/gen function.
Fn,
}
impl fmt::Display for AsyncCoroutineKind {
impl fmt::Display for CoroutineSource {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
AsyncCoroutineKind::Block => "async block",
AsyncCoroutineKind::Closure => "async closure body",
AsyncCoroutineKind::Fn => "async fn body",
CoroutineSource::Block => "async block",
CoroutineSource::Closure => "async closure body",
CoroutineSource::Fn => "async fn body",
})
}
}
impl AsyncCoroutineKind {
impl CoroutineSource {
pub fn descr(&self) -> &'static str {
match self {
AsyncCoroutineKind::Block => "`async` block",
AsyncCoroutineKind::Closure => "`async` closure body",
AsyncCoroutineKind::Fn => "`async fn` body",
CoroutineSource::Block => "`async` block",
CoroutineSource::Closure => "`async` closure body",
CoroutineSource::Fn => "`async fn` body",
}
}
}