1
Fork 0

s/generator/coroutine/

This commit is contained in:
Oli Scherer 2023-10-19 21:46:28 +00:00
parent 60956837cf
commit e96ce20b34
468 changed files with 2201 additions and 2197 deletions

View file

@ -126,7 +126,7 @@ impl DefKind {
///
/// If you have access to `TyCtxt`, use `TyCtxt::def_descr` or
/// `TyCtxt::def_kind_descr` instead, because they give better
/// information for generators and associated functions.
/// information for coroutines and associated functions.
pub fn descr(self, def_id: DefId) -> &'static str {
match self {
DefKind::Fn => "function",
@ -161,7 +161,7 @@ impl DefKind {
DefKind::Field => "field",
DefKind::Impl { .. } => "implementation",
DefKind::Closure => "closure",
DefKind::Coroutine => "generator",
DefKind::Coroutine => "coroutine",
DefKind::ExternCrate => "extern crate",
DefKind::GlobalAsm => "global assembly block",
}
@ -171,7 +171,7 @@ impl DefKind {
///
/// If you have access to `TyCtxt`, use `TyCtxt::def_descr_article` or
/// `TyCtxt::def_kind_descr_article` instead, because they give better
/// information for generators and associated functions.
/// information for coroutines and associated functions.
pub fn article(&self) -> &'static str {
match *self {
DefKind::AssocTy

View file

@ -1485,7 +1485,7 @@ pub struct BodyId {
///
/// - an `params` array containing the `(x, y)` pattern
/// - a `value` containing the `x + y` expression (maybe wrapped in a block)
/// - `generator_kind` would be `None`
/// - `coroutine_kind` would be `None`
///
/// All bodies have an **owner**, which can be accessed via the HIR
/// map using `body_owner_def_id()`.
@ -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<CoroutineKind>,
pub coroutine_kind: Option<CoroutineKind>,
}
impl<'hir> Body<'hir> {
@ -1501,19 +1501,19 @@ impl<'hir> Body<'hir> {
BodyId { hir_id: self.value.hir_id }
}
pub fn generator_kind(&self) -> Option<CoroutineKind> {
self.generator_kind
pub fn coroutine_kind(&self) -> Option<CoroutineKind> {
self.coroutine_kind
}
}
/// The type of source expression that caused this generator to be created.
/// The type of source expression that caused this coroutine to be created.
#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum CoroutineKind {
/// An explicit `async` block or the body of an async function.
Async(AsyncCoroutineKind),
/// A generator literal created via a `yield` inside a closure.
/// A coroutine literal created via a `yield` inside a closure.
Gen,
}
@ -1521,7 +1521,7 @@ impl fmt::Display for CoroutineKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
CoroutineKind::Async(k) => fmt::Display::fmt(k, f),
CoroutineKind::Gen => f.write_str("generator"),
CoroutineKind::Gen => f.write_str("coroutine"),
}
}
}
@ -1530,12 +1530,12 @@ impl CoroutineKind {
pub fn descr(&self) -> &'static str {
match self {
CoroutineKind::Async(ask) => ask.descr(),
CoroutineKind::Gen => "generator",
CoroutineKind::Gen => "coroutine",
}
}
}
/// In the case of a generator created as part of an async construct,
/// In the case of a coroutine created as part of an async construct,
/// which kind of async construct caused it to be created?
///
/// This helps error messages but is also used to drive coercions in
@ -2004,7 +2004,7 @@ pub enum ExprKind<'hir> {
///
/// The `Span` is the argument block `|...|`.
///
/// This may also be a generator literal or an `async block` as indicated by the
/// This may also be a coroutine literal or an `async block` as indicated by the
/// `Option<Movability>`.
Closure(&'hir Closure<'hir>),
/// A block (e.g., `'label: { ... }`).
@ -2055,7 +2055,7 @@ pub enum ExprKind<'hir> {
/// to be repeated; the second is the number of times to repeat it.
Repeat(&'hir Expr<'hir>, ArrayLen),
/// A suspension point for generators (i.e., `yield <expr>`).
/// A suspension point for coroutines (i.e., `yield <expr>`).
Yield(&'hir Expr<'hir>, YieldSource),
/// A placeholder for an expression that wasn't syntactically well formed in some way.
@ -2250,7 +2250,7 @@ impl fmt::Display for YieldSource {
impl From<CoroutineKind> for YieldSource {
fn from(kind: CoroutineKind) -> Self {
match kind {
// Guess based on the kind of the current generator.
// Guess based on the kind of the current coroutine.
CoroutineKind::Gen => Self::Yield,
CoroutineKind::Async(_) => Self::Await { expr: None },
}

View file

@ -62,7 +62,7 @@
//! respectively. (This follows from RPO respecting CFG domination).
//!
//! This order consistency is required in a few places in rustc, for
//! example generator inference, and possibly also HIR borrowck.
//! example coroutine inference, and possibly also HIR borrowck.
use crate::hir::*;
use rustc_ast::walk_list;

View file

@ -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);
CoroutineState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None;
Coroutine, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1);
CoroutineState, sym::coroutine_state, gen_state, Target::Enum, GenericRequirement::None;
Coroutine, sym::coroutine, 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;