diff options
Diffstat (limited to 'compiler/rustc_hir/src')
| -rw-r--r-- | compiler/rustc_hir/src/def.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 46 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/lang_items.rs | 4 |
3 files changed, 30 insertions, 30 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 3a4eb90f7f9..3c7d158c9ad 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -118,7 +118,7 @@ pub enum DefKind { of_trait: bool, }, Closure, - Generator, + Coroutine, } impl DefKind { @@ -161,7 +161,7 @@ impl DefKind { DefKind::Field => "field", DefKind::Impl { .. } => "implementation", DefKind::Closure => "closure", - DefKind::Generator => "generator", + DefKind::Coroutine => "generator", DefKind::ExternCrate => "extern crate", DefKind::GlobalAsm => "global assembly block", } @@ -220,7 +220,7 @@ impl DefKind { | DefKind::LifetimeParam | DefKind::ExternCrate | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::Use | DefKind::ForeignMod | DefKind::GlobalAsm @@ -230,7 +230,7 @@ impl DefKind { #[inline] pub fn is_fn_like(self) -> bool { - matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator) + matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine) } /// Whether `query get_codegen_attrs` should be used with this definition. @@ -240,7 +240,7 @@ impl DefKind { | DefKind::AssocFn | DefKind::Ctor(..) | DefKind::Closure - | DefKind::Generator + | DefKind::Coroutine | DefKind::Static(_) => true, DefKind::Mod | DefKind::Struct diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 3eec66611ed..f60e312937c 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1493,7 +1493,7 @@ pub struct BodyId { pub struct Body<'hir> { pub params: &'hir [Param<'hir>], pub value: &'hir Expr<'hir>, - pub generator_kind: Option<GeneratorKind>, + pub generator_kind: Option<CoroutineKind>, } impl<'hir> Body<'hir> { @@ -1501,7 +1501,7 @@ impl<'hir> Body<'hir> { BodyId { hir_id: self.value.hir_id } } - pub fn generator_kind(&self) -> Option<GeneratorKind> { + pub fn generator_kind(&self) -> Option<CoroutineKind> { self.generator_kind } } @@ -1509,28 +1509,28 @@ impl<'hir> Body<'hir> { /// The type of source expression that caused this generator to be created. #[derive(Clone, PartialEq, Eq, Debug, Copy, Hash)] #[derive(HashStable_Generic, Encodable, Decodable)] -pub enum GeneratorKind { +pub enum CoroutineKind { /// An explicit `async` block or the body of an async function. - Async(AsyncGeneratorKind), + Async(AsyncCoroutineKind), /// A generator literal created via a `yield` inside a closure. Gen, } -impl fmt::Display for GeneratorKind { +impl fmt::Display for CoroutineKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - GeneratorKind::Async(k) => fmt::Display::fmt(k, f), - GeneratorKind::Gen => f.write_str("generator"), + CoroutineKind::Async(k) => fmt::Display::fmt(k, f), + CoroutineKind::Gen => f.write_str("generator"), } } } -impl GeneratorKind { +impl CoroutineKind { pub fn descr(&self) -> &'static str { match self { - GeneratorKind::Async(ask) => ask.descr(), - GeneratorKind::Gen => "generator", + CoroutineKind::Async(ask) => ask.descr(), + CoroutineKind::Gen => "generator", } } } @@ -1542,7 +1542,7 @@ impl GeneratorKind { /// type-checking (see #60424). #[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)] #[derive(HashStable_Generic, Encodable, Decodable)] -pub enum AsyncGeneratorKind { +pub enum AsyncCoroutineKind { /// An explicit `async` block written by the user. Block, @@ -1553,22 +1553,22 @@ pub enum AsyncGeneratorKind { Fn, } -impl fmt::Display for AsyncGeneratorKind { +impl fmt::Display for AsyncCoroutineKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { - AsyncGeneratorKind::Block => "async block", - AsyncGeneratorKind::Closure => "async closure body", - AsyncGeneratorKind::Fn => "async fn body", + AsyncCoroutineKind::Block => "async block", + AsyncCoroutineKind::Closure => "async closure body", + AsyncCoroutineKind::Fn => "async fn body", }) } } -impl AsyncGeneratorKind { +impl AsyncCoroutineKind { pub fn descr(&self) -> &'static str { match self { - AsyncGeneratorKind::Block => "`async` block", - AsyncGeneratorKind::Closure => "`async` closure body", - AsyncGeneratorKind::Fn => "`async fn` body", + AsyncCoroutineKind::Block => "`async` block", + AsyncCoroutineKind::Closure => "`async` closure body", + AsyncCoroutineKind::Fn => "`async fn` body", } } } @@ -2247,12 +2247,12 @@ impl fmt::Display for YieldSource { } } -impl From<GeneratorKind> for YieldSource { - fn from(kind: GeneratorKind) -> Self { +impl From<CoroutineKind> for YieldSource { + fn from(kind: CoroutineKind) -> Self { match kind { // Guess based on the kind of the current generator. - GeneratorKind::Gen => Self::Yield, - GeneratorKind::Async(_) => Self::Await { expr: None }, + CoroutineKind::Gen => Self::Yield, + CoroutineKind::Async(_) => Self::Await { expr: None }, } } } diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 4a89a6f7e39..b13eb3b5e7a 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -211,8 +211,8 @@ language_item_table! { FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None; Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0); - GeneratorState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None; - Generator, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1); + CoroutineState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None; + Coroutine, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1); Unpin, sym::unpin, unpin_trait, Target::Trait, GenericRequirement::None; Pin, sym::pin, pin_type, Target::Struct, GenericRequirement::None; |
