1
Fork 0

s/Generator/Coroutine/

This commit is contained in:
Oli Scherer 2023-10-19 16:06:43 +00:00
parent 96027d945b
commit 60956837cf
310 changed files with 1271 additions and 1271 deletions

View file

@ -240,7 +240,7 @@ impl<'hir> Map<'hir> {
Node::Field(_) => DefKind::Field,
Node::Expr(expr) => match expr.kind {
ExprKind::Closure(Closure { movability: None, .. }) => DefKind::Closure,
ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Generator,
ExprKind::Closure(Closure { movability: Some(_), .. }) => DefKind::Coroutine,
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
},
Node::GenericParam(param) => match param.kind {
@ -445,7 +445,7 @@ impl<'hir> Map<'hir> {
}
DefKind::InlineConst => BodyOwnerKind::Const { inline: true },
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn,
DefKind::Closure | DefKind::Generator => BodyOwnerKind::Closure,
DefKind::Closure | DefKind::Coroutine => BodyOwnerKind::Closure,
DefKind::Static(mt) => BodyOwnerKind::Static(mt),
dk => bug!("{:?} is not a body node: {:?}", def_id, dk),
}

View file

@ -17,7 +17,7 @@ use rustc_data_structures::captures::Captures;
use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
use rustc_hir::{self, GeneratorKind, ImplicitSelfKind};
use rustc_hir::{self, CoroutineKind, ImplicitSelfKind};
use rustc_hir::{self as hir, HirId};
use rustc_session::Session;
use rustc_target::abi::{FieldIdx, VariantIdx};
@ -246,19 +246,19 @@ impl<'tcx> MirSource<'tcx> {
}
#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorInfo<'tcx> {
pub struct CoroutineInfo<'tcx> {
/// The yield type of the function, if it is a generator.
pub yield_ty: Option<Ty<'tcx>>,
/// Generator drop glue.
/// Coroutine drop glue.
pub generator_drop: Option<Body<'tcx>>,
/// The layout of a generator. Produced by the state transformation.
pub generator_layout: Option<GeneratorLayout<'tcx>>,
pub generator_layout: Option<CoroutineLayout<'tcx>>,
/// If this is a generator then record the type of source expression that caused this generator
/// to be created.
pub generator_kind: GeneratorKind,
pub generator_kind: CoroutineKind,
}
/// The lowered representation of a single function.
@ -284,7 +284,7 @@ pub struct Body<'tcx> {
/// and used for debuginfo. Indexed by a `SourceScope`.
pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
pub generator: Option<Box<GeneratorInfo<'tcx>>>,
pub generator: Option<Box<CoroutineInfo<'tcx>>>,
/// Declarations of locals.
///
@ -365,7 +365,7 @@ impl<'tcx> Body<'tcx> {
arg_count: usize,
var_debug_info: Vec<VarDebugInfo<'tcx>>,
span: Span,
generator_kind: Option<GeneratorKind>,
generator_kind: Option<CoroutineKind>,
tainted_by_errors: Option<ErrorGuaranteed>,
) -> Self {
// We need `arg_count` locals, and one for the return place.
@ -383,7 +383,7 @@ impl<'tcx> Body<'tcx> {
basic_blocks: BasicBlocks::new(basic_blocks),
source_scopes,
generator: generator_kind.map(|generator_kind| {
Box::new(GeneratorInfo {
Box::new(CoroutineInfo {
yield_ty: None,
generator_drop: None,
generator_layout: None,
@ -552,7 +552,7 @@ impl<'tcx> Body<'tcx> {
}
#[inline]
pub fn generator_layout(&self) -> Option<&GeneratorLayout<'tcx>> {
pub fn generator_layout(&self) -> Option<&CoroutineLayout<'tcx>> {
self.generator.as_ref().and_then(|generator| generator.generator_layout.as_ref())
}
@ -562,7 +562,7 @@ impl<'tcx> Body<'tcx> {
}
#[inline]
pub fn generator_kind(&self) -> Option<GeneratorKind> {
pub fn generator_kind(&self) -> Option<CoroutineKind> {
self.generator.as_ref().map(|generator| generator.generator_kind)
}

View file

@ -782,7 +782,7 @@ impl<'tcx> TerminatorKind<'tcx> {
Goto { .. } => write!(fmt, "goto"),
SwitchInt { discr, .. } => write!(fmt, "switchInt({discr:?})"),
Return => write!(fmt, "return"),
GeneratorDrop => write!(fmt, "generator_drop"),
CoroutineDrop => write!(fmt, "generator_drop"),
UnwindResume => write!(fmt, "resume"),
UnwindTerminate(reason) => {
write!(fmt, "abort({})", reason.as_short_str())
@ -865,7 +865,7 @@ impl<'tcx> TerminatorKind<'tcx> {
pub fn fmt_successor_labels(&self) -> Vec<Cow<'static, str>> {
use self::TerminatorKind::*;
match *self {
Return | UnwindResume | UnwindTerminate(_) | Unreachable | GeneratorDrop => vec![],
Return | UnwindResume | UnwindTerminate(_) | Unreachable | CoroutineDrop => vec![],
Goto { .. } => vec!["".into()],
SwitchInt { ref targets, .. } => targets
.values
@ -1046,7 +1046,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
struct_fmt.finish()
}),
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
AggregateKind::Coroutine(def_id, _, _) => ty::tls::with(|tcx| {
let name = format!("{{generator@{:?}}}", tcx.def_span(def_id));
let mut struct_fmt = fmt.debug_struct(&name);
@ -1301,7 +1301,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
self.push(&format!("+ args: {args:#?}"));
}
AggregateKind::Generator(def_id, args, movability) => {
AggregateKind::Coroutine(def_id, args, movability) => {
self.push("generator");
self.push(&format!("+ def_id: {def_id:?}"));
self.push(&format!("+ args: {args:#?}"));

View file

@ -133,11 +133,11 @@ pub struct UnsafetyCheckResult {
rustc_index::newtype_index! {
#[derive(HashStable)]
#[debug_format = "_{}"]
pub struct GeneratorSavedLocal {}
pub struct CoroutineSavedLocal {}
}
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorSavedTy<'tcx> {
pub struct CoroutineSavedTy<'tcx> {
pub ty: Ty<'tcx>,
/// Source info corresponding to the local in the original MIR body.
pub source_info: SourceInfo,
@ -147,16 +147,16 @@ pub struct GeneratorSavedTy<'tcx> {
/// The layout of generator state.
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct GeneratorLayout<'tcx> {
pub struct CoroutineLayout<'tcx> {
/// The type of every local stored inside the generator.
pub field_tys: IndexVec<GeneratorSavedLocal, GeneratorSavedTy<'tcx>>,
pub field_tys: IndexVec<CoroutineSavedLocal, CoroutineSavedTy<'tcx>>,
/// The name for debuginfo.
pub field_names: IndexVec<GeneratorSavedLocal, Option<Symbol>>,
pub field_names: IndexVec<CoroutineSavedLocal, Option<Symbol>>,
/// Which of the above fields are in each variant. Note that one field may
/// be stored in multiple variants.
pub variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, GeneratorSavedLocal>>,
pub variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>>,
/// The source that led to each variant being created (usually, a yield or
/// await).
@ -167,10 +167,10 @@ pub struct GeneratorLayout<'tcx> {
/// layout.
#[type_foldable(identity)]
#[type_visitable(ignore)]
pub storage_conflicts: BitMatrix<GeneratorSavedLocal, GeneratorSavedLocal>,
pub storage_conflicts: BitMatrix<CoroutineSavedLocal, CoroutineSavedLocal>,
}
impl Debug for GeneratorLayout<'_> {
impl Debug for CoroutineLayout<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
/// Prints an iterator of (key, value) tuples as a map.
struct MapPrinter<'a, K, V>(Cell<Option<Box<dyn Iterator<Item = (K, V)> + 'a>>>);
@ -194,7 +194,7 @@ impl Debug for GeneratorLayout<'_> {
}
impl Debug for GenVariantPrinter {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let variant_name = ty::GeneratorArgs::variant_name(self.0);
let variant_name = ty::CoroutineArgs::variant_name(self.0);
if fmt.alternate() {
write!(fmt, "{:9}({:?})", variant_name, self.0)
} else {
@ -211,7 +211,7 @@ impl Debug for GeneratorLayout<'_> {
}
}
fmt.debug_struct("GeneratorLayout")
fmt.debug_struct("CoroutineLayout")
.field("field_tys", &MapPrinter::new(self.field_tys.iter_enumerated()))
.field(
"variant_fields",

View file

@ -15,7 +15,7 @@ use crate::ty::{Region, UserTypeAnnotationIndex};
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir};
use rustc_hir::{self, GeneratorKind};
use rustc_hir::{self, CoroutineKind};
use rustc_index::IndexVec;
use rustc_target::abi::{FieldIdx, VariantIdx};
@ -82,7 +82,7 @@ pub enum MirPhase {
/// that Rust itself has them. Where exactly these are is generally subject to change, and so we
/// don't document this here. Runtime MIR has most retags explicit (though implicit retags
/// can still occur at `Rvalue::{Ref,AddrOf}`).
/// - Generator bodies: In analysis MIR, locals may actually be behind a pointer that user code has
/// - Coroutine bodies: In analysis MIR, locals may actually be behind a pointer that user code has
/// access to. This occurs in generator bodies. Such locals do not behave like other locals,
/// because they eg may be aliased in surprising ways. Runtime MIR has no such special locals -
/// all generator bodies are lowered and so all places that look like locals really are locals.
@ -137,7 +137,7 @@ pub enum RuntimePhase {
/// In addition to the semantic changes, beginning with this phase, the following variants are
/// disallowed:
/// * [`TerminatorKind::Yield`]
/// * [`TerminatorKind::GeneratorDrop`]
/// * [`TerminatorKind::CoroutineDrop`]
/// * [`Rvalue::Aggregate`] for any `AggregateKind` except `Array`
/// * [`PlaceElem::OpaqueCast`]
///
@ -627,7 +627,7 @@ pub enum TerminatorKind<'tcx> {
/// aliasing model.
///
/// If the body is a generator body, this has slightly different semantics; it instead causes a
/// `GeneratorState::Returned(_0)` to be created (as if by an `Aggregate` rvalue) and assigned
/// `CoroutineState::Returned(_0)` to be created (as if by an `Aggregate` rvalue) and assigned
/// to the return place.
Return,
@ -710,7 +710,7 @@ pub enum TerminatorKind<'tcx> {
/// Marks a suspend point.
///
/// Like `Return` terminators in generator bodies, this computes `value` and then a
/// `GeneratorState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to
/// `CoroutineState::Yielded(value)` as if by `Aggregate` rvalue. That value is then assigned to
/// the return place of the function calling this one, and execution continues in the calling
/// function. When next invoked with the same first argument, execution of this function
/// continues at the `resume` basic block, with the second argument written to the `resume_arg`
@ -740,7 +740,7 @@ pub enum TerminatorKind<'tcx> {
///
/// **Needs clarification**: Are there type system constraints on these terminators? Should
/// there be a "block type" like `cleanup` blocks for them?
GeneratorDrop,
CoroutineDrop,
/// A block where control flow only ever takes one real path, but borrowck needs to be more
/// conservative.
@ -815,7 +815,7 @@ impl TerminatorKind<'_> {
TerminatorKind::Call { .. } => "Call",
TerminatorKind::Assert { .. } => "Assert",
TerminatorKind::Yield { .. } => "Yield",
TerminatorKind::GeneratorDrop => "GeneratorDrop",
TerminatorKind::CoroutineDrop => "CoroutineDrop",
TerminatorKind::FalseEdge { .. } => "FalseEdge",
TerminatorKind::FalseUnwind { .. } => "FalseUnwind",
TerminatorKind::InlineAsm { .. } => "InlineAsm",
@ -883,8 +883,8 @@ pub enum AssertKind<O> {
OverflowNeg(O),
DivisionByZero(O),
RemainderByZero(O),
ResumedAfterReturn(GeneratorKind),
ResumedAfterPanic(GeneratorKind),
ResumedAfterReturn(CoroutineKind),
ResumedAfterPanic(CoroutineKind),
MisalignedPointerDereference { required: O, found: O },
}
@ -1278,8 +1278,8 @@ pub enum Rvalue<'tcx> {
/// `dest = Foo { x: ..., y: ... }` from `dest.x = ...; dest.y = ...;` in the case that `Foo`
/// has a destructor.
///
/// Disallowed after deaggregation for all aggregate kinds except `Array` and `Generator`. After
/// generator lowering, `Generator` aggregate kinds are disallowed too.
/// Disallowed after deaggregation for all aggregate kinds except `Array` and `Coroutine`. After
/// generator lowering, `Coroutine` aggregate kinds are disallowed too.
Aggregate(Box<AggregateKind<'tcx>>, IndexVec<FieldIdx, Operand<'tcx>>),
/// Transmutes a `*mut u8` into shallow-initialized `Box<T>`.
@ -1344,7 +1344,7 @@ pub enum AggregateKind<'tcx> {
Adt(DefId, VariantIdx, GenericArgsRef<'tcx>, Option<UserTypeAnnotationIndex>, Option<FieldIdx>),
Closure(DefId, GenericArgsRef<'tcx>),
Generator(DefId, GenericArgsRef<'tcx>, hir::Movability),
Coroutine(DefId, GenericArgsRef<'tcx>, hir::Movability),
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]

View file

@ -205,7 +205,7 @@ impl<'tcx> Rvalue<'tcx> {
}
AggregateKind::Adt(did, _, args, _, _) => tcx.type_of(did).instantiate(tcx, args),
AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
AggregateKind::Generator(did, args, movability) => {
AggregateKind::Coroutine(did, args, movability) => {
Ty::new_generator(tcx, did, args, movability)
}
},

View file

@ -139,10 +139,10 @@ impl<O> AssertKind<O> {
Overflow(op, _, _) => bug!("{:?} cannot overflow", op),
DivisionByZero(_) => "attempt to divide by zero",
RemainderByZero(_) => "attempt to calculate the remainder with a divisor of zero",
ResumedAfterReturn(GeneratorKind::Gen) => "generator resumed after completion",
ResumedAfterReturn(GeneratorKind::Async(_)) => "`async fn` resumed after completion",
ResumedAfterPanic(GeneratorKind::Gen) => "generator resumed after panicking",
ResumedAfterPanic(GeneratorKind::Async(_)) => "`async fn` resumed after panicking",
ResumedAfterReturn(CoroutineKind::Gen) => "generator resumed after completion",
ResumedAfterReturn(CoroutineKind::Async(_)) => "`async fn` resumed after completion",
ResumedAfterPanic(CoroutineKind::Gen) => "generator resumed after panicking",
ResumedAfterPanic(CoroutineKind::Async(_)) => "`async fn` resumed after panicking",
BoundsCheck { .. } | MisalignedPointerDereference { .. } => {
bug!("Unexpected AssertKind")
}
@ -228,10 +228,10 @@ impl<O> AssertKind<O> {
OverflowNeg(_) => middle_assert_overflow_neg,
DivisionByZero(_) => middle_assert_divide_by_zero,
RemainderByZero(_) => middle_assert_remainder_by_zero,
ResumedAfterReturn(GeneratorKind::Async(_)) => middle_assert_async_resume_after_return,
ResumedAfterReturn(GeneratorKind::Gen) => middle_assert_generator_resume_after_return,
ResumedAfterPanic(GeneratorKind::Async(_)) => middle_assert_async_resume_after_panic,
ResumedAfterPanic(GeneratorKind::Gen) => middle_assert_generator_resume_after_panic,
ResumedAfterReturn(CoroutineKind::Async(_)) => middle_assert_async_resume_after_return,
ResumedAfterReturn(CoroutineKind::Gen) => middle_assert_generator_resume_after_return,
ResumedAfterPanic(CoroutineKind::Async(_)) => middle_assert_async_resume_after_panic,
ResumedAfterPanic(CoroutineKind::Gen) => middle_assert_generator_resume_after_panic,
MisalignedPointerDereference { .. } => middle_assert_misaligned_ptr_deref,
}
@ -331,7 +331,7 @@ impl<'tcx> TerminatorKind<'tcx> {
}
UnwindResume
| UnwindTerminate(_)
| GeneratorDrop
| CoroutineDrop
| Return
| Unreachable
| Call { target: None, unwind: _, .. }
@ -373,7 +373,7 @@ impl<'tcx> TerminatorKind<'tcx> {
}
UnwindResume
| UnwindTerminate(_)
| GeneratorDrop
| CoroutineDrop
| Return
| Unreachable
| Call { target: None, unwind: _, .. }
@ -392,7 +392,7 @@ impl<'tcx> TerminatorKind<'tcx> {
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return
| TerminatorKind::Unreachable
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Yield { .. }
| TerminatorKind::SwitchInt { .. }
| TerminatorKind::FalseEdge { .. } => None,
@ -411,7 +411,7 @@ impl<'tcx> TerminatorKind<'tcx> {
| TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return
| TerminatorKind::Unreachable
| TerminatorKind::GeneratorDrop
| TerminatorKind::CoroutineDrop
| TerminatorKind::Yield { .. }
| TerminatorKind::SwitchInt { .. }
| TerminatorKind::FalseEdge { .. } => None,
@ -493,7 +493,7 @@ impl<'tcx> TerminatorKind<'tcx> {
pub fn edges(&self) -> TerminatorEdges<'_, 'tcx> {
use TerminatorKind::*;
match *self {
Return | UnwindResume | UnwindTerminate(_) | GeneratorDrop | Unreachable => {
Return | UnwindResume | UnwindTerminate(_) | CoroutineDrop | Unreachable => {
TerminatorEdges::None
}

View file

@ -19,8 +19,8 @@ TrivialTypeTraversalImpls! {
hir::Movability,
BasicBlock,
SwitchTargets,
GeneratorKind,
GeneratorSavedLocal,
CoroutineKind,
CoroutineSavedLocal,
}
TrivialTypeTraversalImpls! {

View file

@ -473,7 +473,7 @@ macro_rules! make_mir_visitor {
TerminatorKind::Goto { .. } |
TerminatorKind::UnwindResume |
TerminatorKind::UnwindTerminate(_) |
TerminatorKind::GeneratorDrop |
TerminatorKind::CoroutineDrop |
TerminatorKind::Unreachable |
TerminatorKind::FalseEdge { .. } |
TerminatorKind::FalseUnwind { .. } => {}
@ -735,7 +735,7 @@ macro_rules! make_mir_visitor {
) => {
self.visit_args(closure_args, location);
}
AggregateKind::Generator(
AggregateKind::Coroutine(
_,
generator_args,
_movability,

View file

@ -210,7 +210,7 @@ trivial! {
Option<rustc_attr::Stability>,
Option<rustc_data_structures::svh::Svh>,
Option<rustc_hir::def::DefKind>,
Option<rustc_hir::GeneratorKind>,
Option<rustc_hir::CoroutineKind>,
Option<rustc_hir::HirId>,
Option<rustc_middle::middle::stability::DeprecationEntry>,
Option<rustc_middle::ty::Destructor>,
@ -239,7 +239,7 @@ trivial! {
rustc_hir::def::DefKind,
rustc_hir::Defaultness,
rustc_hir::definitions::DefKey,
rustc_hir::GeneratorKind,
rustc_hir::CoroutineKind,
rustc_hir::HirId,
rustc_hir::IsAsync,
rustc_hir::ItemLocalId,

View file

@ -554,7 +554,7 @@ rustc_queries! {
separate_provide_extern
}
query mir_generator_witnesses(key: DefId) -> &'tcx Option<mir::GeneratorLayout<'tcx>> {
query mir_generator_witnesses(key: DefId) -> &'tcx Option<mir::CoroutineLayout<'tcx>> {
arena_cache
desc { |tcx| "generator witness types for `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
@ -744,7 +744,7 @@ rustc_queries! {
}
/// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
query generator_kind(def_id: DefId) -> Option<hir::CoroutineKind> {
desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) }
separate_provide_extern
}

View file

@ -302,7 +302,7 @@ pub enum ObligationCauseCode<'tcx> {
/// Captured closure type must be `Sized`.
SizedClosureCapture(LocalDefId),
/// Types live across generator yields must be `Sized`.
SizedGeneratorInterior(LocalDefId),
SizedCoroutineInterior(LocalDefId),
/// `[expr; N]` requires `type_of(expr): Copy`.
RepeatElementCopy {
/// If element is a `const fn` we display a help message suggesting to move the

View file

@ -136,9 +136,9 @@ pub enum SelectionCandidate<'tcx> {
is_const: bool,
},
/// Implementation of a `Generator` trait by one of the anonymous types
/// Implementation of a `Coroutine` trait by one of the anonymous types
/// generated for a generator.
GeneratorCandidate,
CoroutineCandidate,
/// Implementation of a `Future` trait by one of the generator types
/// generated for an async construct.

View file

@ -763,7 +763,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Returns `true` if the node pointed to by `def_id` is a generator for an async construct.
pub fn generator_is_async(self, def_id: DefId) -> bool {
matches!(self.generator_kind(def_id), Some(hir::GeneratorKind::Async(_)))
matches!(self.generator_kind(def_id), Some(hir::CoroutineKind::Async(_)))
}
pub fn stability(self) -> &'tcx stability::Index {
@ -1382,8 +1382,8 @@ impl<'tcx> TyCtxt<'tcx> {
FnDef,
FnPtr,
Placeholder,
Generator,
GeneratorWitness,
Coroutine,
CoroutineWitness,
Dynamic,
Closure,
Tuple,

View file

@ -482,8 +482,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
FnDef(..)
| Closure(..)
| Infer(..)
| Generator(..)
| GeneratorWitness(..)
| Coroutine(..)
| CoroutineWitness(..)
| Bound(_, _)
| Placeholder(_)
| Error(_) => {
@ -567,8 +567,8 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
// FIXME(compiler-errors): We could replace these with infer, I guess.
Closure(..)
| Infer(..)
| Generator(..)
| GeneratorWitness(..)
| Coroutine(..)
| CoroutineWitness(..)
| Bound(_, _)
| Placeholder(_)
| Error(_) => {

View file

@ -241,8 +241,8 @@ impl<'tcx> Ty<'tcx> {
}
ty::Dynamic(..) => "trait object".into(),
ty::Closure(..) => "closure".into(),
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::GeneratorWitness(..) => "generator witness".into(),
ty::Coroutine(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::CoroutineWitness(..) => "generator witness".into(),
ty::Infer(ty::TyVar(_)) => "inferred type".into(),
ty::Infer(ty::IntVar(_)) => "integer".into(),
ty::Infer(ty::FloatVar(_)) => "floating-point number".into(),
@ -299,8 +299,8 @@ impl<'tcx> Ty<'tcx> {
ty::FnPtr(_) => "fn pointer".into(),
ty::Dynamic(..) => "trait object".into(),
ty::Closure(..) => "closure".into(),
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::GeneratorWitness(..) => "generator witness".into(),
ty::Coroutine(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
ty::CoroutineWitness(..) => "generator witness".into(),
ty::Tuple(..) => "tuple".into(),
ty::Placeholder(..) => "higher-ranked type".into(),
ty::Bound(..) => "bound type variable".into(),

View file

@ -28,8 +28,8 @@ pub enum SimplifiedType {
MarkerTraitObject,
Trait(DefId),
Closure(DefId),
Generator(DefId),
GeneratorWitness(DefId),
Coroutine(DefId),
CoroutineWitness(DefId),
Function(usize),
Placeholder,
}
@ -128,8 +128,8 @@ pub fn simplify_type<'tcx>(
},
ty::Ref(_, _, mutbl) => Some(SimplifiedType::Ref(mutbl)),
ty::FnDef(def_id, _) | ty::Closure(def_id, _) => Some(SimplifiedType::Closure(def_id)),
ty::Generator(def_id, _, _) => Some(SimplifiedType::Generator(def_id)),
ty::GeneratorWitness(def_id, _) => Some(SimplifiedType::GeneratorWitness(def_id)),
ty::Coroutine(def_id, _, _) => Some(SimplifiedType::Coroutine(def_id)),
ty::CoroutineWitness(def_id, _) => Some(SimplifiedType::CoroutineWitness(def_id)),
ty::Never => Some(SimplifiedType::Never),
ty::Tuple(tys) => Some(SimplifiedType::Tuple(tys.len())),
ty::FnPtr(f) => Some(SimplifiedType::Function(f.skip_binder().inputs().len())),
@ -164,8 +164,8 @@ impl SimplifiedType {
| SimplifiedType::Foreign(d)
| SimplifiedType::Trait(d)
| SimplifiedType::Closure(d)
| SimplifiedType::Generator(d)
| SimplifiedType::GeneratorWitness(d) => Some(d),
| SimplifiedType::Coroutine(d)
| SimplifiedType::CoroutineWitness(d) => Some(d),
_ => None,
}
}
@ -234,8 +234,8 @@ impl DeepRejectCtxt {
| ty::Foreign(..) => {}
ty::FnDef(..)
| ty::Closure(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Placeholder(..)
| ty::Bound(..)
| ty::Infer(_) => bug!("unexpected impl_ty: {impl_ty}"),
@ -310,7 +310,7 @@ impl DeepRejectCtxt {
},
// Impls cannot contain these types as these cannot be named directly.
ty::FnDef(..) | ty::Closure(..) | ty::Generator(..) => false,
ty::FnDef(..) | ty::Closure(..) | ty::Coroutine(..) => false,
// Placeholder types don't unify with anything on their own
ty::Placeholder(..) | ty::Bound(..) => false,
@ -337,7 +337,7 @@ impl DeepRejectCtxt {
ty::Error(_) => true,
ty::GeneratorWitness(..) => {
ty::CoroutineWitness(..) => {
bug!("unexpected obligation type: {:?}", obligation_ty)
}
}

View file

@ -111,7 +111,7 @@ impl FlagComputation {
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
}
ty::Generator(_, args, _) => {
ty::Coroutine(_, args, _) => {
let args = args.as_generator();
let should_remove_further_specializable =
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
@ -127,7 +127,7 @@ impl FlagComputation {
self.add_ty(args.tupled_upvars_ty());
}
ty::GeneratorWitness(_, args) => {
ty::CoroutineWitness(_, args) => {
let should_remove_further_specializable =
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
self.add_args(args);

View file

@ -2,7 +2,7 @@
use crate::ty::codec::{TyDecoder, TyEncoder};
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
use crate::ty::sty::{ClosureArgs, GeneratorArgs, InlineConstArgs};
use crate::ty::sty::{ClosureArgs, CoroutineArgs, InlineConstArgs};
use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
@ -267,11 +267,11 @@ impl<'tcx> GenericArgs<'tcx> {
}
/// Interpret these generic args as the args of a generator type.
/// Generator args have a particular structure controlled by the
/// Coroutine args have a particular structure controlled by the
/// compiler that encodes information like the signature and generator kind;
/// see `ty::GeneratorArgs` struct for more comments.
pub fn as_generator(&'tcx self) -> GeneratorArgs<'tcx> {
GeneratorArgs { args: self }
/// see `ty::CoroutineArgs` struct for more comments.
pub fn as_generator(&'tcx self) -> CoroutineArgs<'tcx> {
CoroutineArgs { args: self }
}
/// Interpret these generic args as the args of an inline const.

View file

@ -689,7 +689,7 @@ fn polymorphize<'tcx>(
Ty::new_closure(self.tcx, def_id, polymorphized_args)
}
}
ty::Generator(def_id, args, movability) => {
ty::Coroutine(def_id, args, movability) => {
let polymorphized_args =
polymorphize(self.tcx, ty::InstanceDef::Item(def_id), args);
if args == polymorphized_args {

View file

@ -809,7 +809,7 @@ where
| ty::FnPtr(_)
| ty::Never
| ty::FnDef(..)
| ty::GeneratorWitness(..)
| ty::CoroutineWitness(..)
| ty::Foreign(..)
| ty::Dynamic(_, _, ty::Dyn) => {
bug!("TyAndLayout::field({:?}): not applicable", this)
@ -905,7 +905,7 @@ where
i,
),
ty::Generator(def_id, ref args, _) => match this.variants {
ty::Coroutine(def_id, ref args, _) => match this.variants {
Variants::Single { index } => TyMaybeWithLayout::Ty(
args.as_generator()
.state_tys(def_id, tcx)

View file

@ -20,7 +20,7 @@ pub use self::Variance::*;
use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
use crate::metadata::ModChild;
use crate::middle::privacy::EffectiveVisibilities;
use crate::mir::{Body, GeneratorLayout};
use crate::mir::{Body, CoroutineLayout};
use crate::query::Providers;
use crate::traits::{self, Reveal};
use crate::ty;
@ -98,8 +98,8 @@ pub use self::sty::BoundRegionKind::*;
pub use self::sty::{
AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
BoundVariableKind, CanonicalPolyFnSig, ClosureArgs, ClosureArgsParts, ConstKind, ConstVid,
EarlyBoundRegion, EffectVid, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef,
FnSig, FreeRegion, GenSig, GeneratorArgs, GeneratorArgsParts, InlineConstArgs,
CoroutineArgs, CoroutineArgsParts, EarlyBoundRegion, EffectVid, ExistentialPredicate,
ExistentialProjection, ExistentialTraitRef, FnSig, FreeRegion, GenSig, InlineConstArgs,
InlineConstArgsParts, ParamConst, ParamTy, PolyExistentialPredicate, PolyExistentialProjection,
PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef, Region, RegionKind, RegionVid,
TraitRef, TyKind, TypeAndMut, UpvarArgs, VarianceDiagInfo,
@ -2423,7 +2423,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Returns layout of a generator. Layout might be unavailable if the
/// generator is tainted by errors.
pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx GeneratorLayout<'tcx>> {
pub fn generator_layout(self, def_id: DefId) -> Option<&'tcx CoroutineLayout<'tcx>> {
self.optimized_mir(def_id).generator_layout()
}

View file

@ -152,12 +152,12 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
Ty::new_closure(self.tcx, def_id, args)
}
ty::Generator(def_id, args, movability) => {
ty::Coroutine(def_id, args, movability) => {
let args = self.fold_closure_args(def_id, args);
Ty::new_generator(self.tcx, def_id, args, movability)
}
ty::GeneratorWitness(def_id, args) => {
ty::CoroutineWitness(def_id, args) => {
let args = self.fold_closure_args(def_id, args);
Ty::new_generator_witness(self.tcx, def_id, args)
}

View file

@ -82,7 +82,7 @@ trivially_parameterized_over_tcx! {
rustc_attr::Stability,
rustc_hir::Constness,
rustc_hir::Defaultness,
rustc_hir::GeneratorKind,
rustc_hir::CoroutineKind,
rustc_hir::IsAsync,
rustc_hir::LangItem,
rustc_hir::def::DefKind,
@ -123,7 +123,7 @@ macro_rules! parameterized_over_tcx {
parameterized_over_tcx! {
crate::middle::exported_symbols::ExportedSymbol,
crate::mir::Body,
crate::mir::GeneratorLayout,
crate::mir::CoroutineLayout,
ty::Ty,
ty::FnSig,
ty::GenericPredicates,

View file

@ -261,8 +261,8 @@ fn characteristic_def_id_of_type_cached<'a>(
ty::FnDef(def_id, _)
| ty::Closure(def_id, _)
| ty::Generator(def_id, _, _)
| ty::GeneratorWitness(def_id, _)
| ty::Coroutine(def_id, _, _)
| ty::CoroutineWitness(def_id, _)
| ty::Foreign(def_id) => Some(def_id),
ty::Bool

View file

@ -784,11 +784,11 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
}
ty::Str => p!("str"),
ty::Generator(did, args, movability) => {
ty::Coroutine(did, args, movability) => {
p!(write("{{"));
let generator_kind = self.tcx().generator_kind(did).unwrap();
let should_print_movability =
self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen;
self.should_print_verbose() || generator_kind == hir::CoroutineKind::Gen;
if should_print_movability {
match movability {
@ -828,7 +828,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
p!("}}")
}
ty::GeneratorWitness(did, args) => {
ty::CoroutineWitness(did, args) => {
p!(write("{{"));
if !self.tcx().sess.verbose() {
p!("generator witness");
@ -1048,7 +1048,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
for (assoc_item_def_id, term) in assoc_items {
// Skip printing `<{generator@} as Generator<_>>::Return` from async blocks,
// Skip printing `<{generator@} as Coroutine<_>>::Return` from async blocks,
// unless we can find out what generator return type it comes from.
let term = if let Some(ty) = term.skip_binder().ty()
&& let ty::Alias(ty::Projection, proj) = ty.kind()
@ -1056,7 +1056,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
&& assoc.trait_container(tcx) == tcx.lang_items().gen_trait()
&& assoc.name == rustc_span::sym::Return
{
if let ty::Generator(_, args, _) = args.type_at(0).kind() {
if let ty::Coroutine(_, args, _) = args.type_at(0).kind() {
let return_ty = args.as_generator().return_ty();
if !return_ty.is_ty_var() {
return_ty.into()

View file

@ -352,19 +352,19 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
}
#[derive(PartialEq, Copy, Debug, Clone, TypeFoldable, TypeVisitable)]
struct GeneratorWitness<'tcx>(&'tcx ty::List<Ty<'tcx>>);
struct CoroutineWitness<'tcx>(&'tcx ty::List<Ty<'tcx>>);
impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
impl<'tcx> Relate<'tcx> for CoroutineWitness<'tcx> {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
a: GeneratorWitness<'tcx>,
b: GeneratorWitness<'tcx>,
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
a: CoroutineWitness<'tcx>,
b: CoroutineWitness<'tcx>,
) -> RelateResult<'tcx, CoroutineWitness<'tcx>> {
assert_eq!(a.0.len(), b.0.len());
let tcx = relation.tcx();
let types =
tcx.mk_type_list_from_iter(iter::zip(a.0, b.0).map(|(a, b)| relation.relate(a, b)))?;
Ok(GeneratorWitness(types))
Ok(CoroutineWitness(types))
}
}
@ -457,20 +457,20 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
Ok(Ty::new_dynamic(tcx, relation.relate(a_obj, b_obj)?, region_bound, a_repr))
}
(&ty::Generator(a_id, a_args, movability), &ty::Generator(b_id, b_args, _))
(&ty::Coroutine(a_id, a_args, movability), &ty::Coroutine(b_id, b_args, _))
if a_id == b_id =>
{
// All Generator types with the same id represent
// All Coroutine types with the same id represent
// the (anonymous) type of the same generator expression. So
// all of their regions should be equated.
let args = relate_args_invariantly(relation, a_args, b_args)?;
Ok(Ty::new_generator(tcx, a_id, args, movability))
}
(&ty::GeneratorWitness(a_id, a_args), &ty::GeneratorWitness(b_id, b_args))
(&ty::CoroutineWitness(a_id, a_args), &ty::CoroutineWitness(b_id, b_args))
if a_id == b_id =>
{
// All GeneratorWitness types with the same id represent
// All CoroutineWitness types with the same id represent
// the (anonymous) type of the same generator expression. So
// all of their regions should be equated.
let args = relate_args_invariantly(relation, a_args, b_args)?;
@ -710,14 +710,14 @@ impl<'tcx> Relate<'tcx> for ty::ClosureArgs<'tcx> {
}
}
impl<'tcx> Relate<'tcx> for ty::GeneratorArgs<'tcx> {
impl<'tcx> Relate<'tcx> for ty::CoroutineArgs<'tcx> {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
a: ty::GeneratorArgs<'tcx>,
b: ty::GeneratorArgs<'tcx>,
) -> RelateResult<'tcx, ty::GeneratorArgs<'tcx>> {
a: ty::CoroutineArgs<'tcx>,
b: ty::CoroutineArgs<'tcx>,
) -> RelateResult<'tcx, ty::CoroutineArgs<'tcx>> {
let args = relate_args_invariantly(relation, a.args, b.args)?;
Ok(ty::GeneratorArgs { args })
Ok(ty::CoroutineArgs { args })
}
}

View file

@ -654,11 +654,11 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
ty::Ref(r, ty, mutbl) => {
ty::Ref(r.try_fold_with(folder)?, ty.try_fold_with(folder)?, mutbl)
}
ty::Generator(did, args, movability) => {
ty::Generator(did, args.try_fold_with(folder)?, movability)
ty::Coroutine(did, args, movability) => {
ty::Coroutine(did, args.try_fold_with(folder)?, movability)
}
ty::GeneratorWitness(did, args) => {
ty::GeneratorWitness(did, args.try_fold_with(folder)?)
ty::CoroutineWitness(did, args) => {
ty::CoroutineWitness(did, args.try_fold_with(folder)?)
}
ty::Closure(did, args) => ty::Closure(did, args.try_fold_with(folder)?),
ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?),
@ -706,8 +706,8 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for Ty<'tcx> {
r.visit_with(visitor)?;
ty.visit_with(visitor)
}
ty::Generator(_did, ref args, _) => args.visit_with(visitor),
ty::GeneratorWitness(_did, ref args) => args.visit_with(visitor),
ty::Coroutine(_did, ref args, _) => args.visit_with(visitor),
ty::CoroutineWitness(_did, ref args) => args.visit_with(visitor),
ty::Closure(_did, ref args) => args.visit_with(visitor),
ty::Alias(_, ref data) => data.visit_with(visitor),

View file

@ -215,9 +215,9 @@ impl<'tcx> Article for TyKind<'tcx> {
/// closure C (which would then require fixed point iteration to
/// handle). Plus it fixes an ICE. :P
///
/// ## Generators
/// ## Coroutines
///
/// Generators are handled similarly in `GeneratorArgs`. The set of
/// Coroutines are handled similarly in `CoroutineArgs`. The set of
/// type parameters is similar, but `CK` and `CS` are replaced by the
/// following type parameters:
///
@ -352,11 +352,11 @@ impl<'tcx> ClosureArgs<'tcx> {
/// Similar to `ClosureArgs`; see the above documentation for more.
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]
pub struct GeneratorArgs<'tcx> {
pub struct CoroutineArgs<'tcx> {
pub args: GenericArgsRef<'tcx>,
}
pub struct GeneratorArgsParts<'tcx, T> {
pub struct CoroutineArgsParts<'tcx, T> {
pub parent_args: &'tcx [GenericArg<'tcx>],
pub resume_ty: T,
pub yield_ty: T,
@ -365,14 +365,14 @@ pub struct GeneratorArgsParts<'tcx, T> {
pub tupled_upvars_ty: T,
}
impl<'tcx> GeneratorArgs<'tcx> {
/// Construct `GeneratorArgs` from `GeneratorArgsParts`, containing `Args`
impl<'tcx> CoroutineArgs<'tcx> {
/// Construct `CoroutineArgs` from `CoroutineArgsParts`, containing `Args`
/// for the generator parent, alongside additional generator-specific components.
pub fn new(
tcx: TyCtxt<'tcx>,
parts: GeneratorArgsParts<'tcx, Ty<'tcx>>,
) -> GeneratorArgs<'tcx> {
GeneratorArgs {
parts: CoroutineArgsParts<'tcx, Ty<'tcx>>,
) -> CoroutineArgs<'tcx> {
CoroutineArgs {
args: tcx.mk_args_from_iter(
parts.parent_args.iter().copied().chain(
[
@ -390,11 +390,11 @@ impl<'tcx> GeneratorArgs<'tcx> {
}
/// Divides the generator args into their respective components.
/// The ordering assumed here must match that used by `GeneratorArgs::new` above.
fn split(self) -> GeneratorArgsParts<'tcx, GenericArg<'tcx>> {
/// The ordering assumed here must match that used by `CoroutineArgs::new` above.
fn split(self) -> CoroutineArgsParts<'tcx, GenericArg<'tcx>> {
match self.args[..] {
[ref parent_args @ .., resume_ty, yield_ty, return_ty, witness, tupled_upvars_ty] => {
GeneratorArgsParts {
CoroutineArgsParts {
parent_args,
resume_ty,
yield_ty,
@ -408,7 +408,7 @@ impl<'tcx> GeneratorArgs<'tcx> {
}
/// Returns `true` only if enough of the synthetic types are known to
/// allow using all of the methods on `GeneratorArgs` without panicking.
/// allow using all of the methods on `CoroutineArgs` without panicking.
///
/// Used primarily by `ty::print::pretty` to be able to handle generator
/// types that haven't had their synthetic types substituted in.
@ -485,12 +485,12 @@ impl<'tcx> GeneratorArgs<'tcx> {
}
}
impl<'tcx> GeneratorArgs<'tcx> {
/// Generator has not been resumed yet.
impl<'tcx> CoroutineArgs<'tcx> {
/// Coroutine has not been resumed yet.
pub const UNRESUMED: usize = 0;
/// Generator has returned or is completed.
/// Coroutine has returned or is completed.
pub const RETURNED: usize = 1;
/// Generator has been poisoned.
/// Coroutine has been poisoned.
pub const POISONED: usize = 2;
const UNRESUMED_NAME: &'static str = "Unresumed";
@ -513,7 +513,7 @@ impl<'tcx> GeneratorArgs<'tcx> {
tcx: TyCtxt<'tcx>,
variant_index: VariantIdx,
) -> Discr<'tcx> {
// Generators don't support explicit discriminant values, so they are
// Coroutines don't support explicit discriminant values, so they are
// the same as the variant index.
assert!(self.variant_range(def_id, tcx).contains(&variant_index));
Discr { val: variant_index.as_usize() as u128, ty: self.discr_ty(tcx) }
@ -551,7 +551,7 @@ impl<'tcx> GeneratorArgs<'tcx> {
/// This returns the types of the MIR locals which had to be stored across suspension points.
/// It is calculated in rustc_mir_transform::generator::StateTransform.
/// All the types here must be in the tuple in GeneratorInterior.
/// All the types here must be in the tuple in CoroutineInterior.
///
/// The locals are grouped by their variant number. Note that some locals may
/// be repeated in multiple variants.
@ -580,7 +580,7 @@ impl<'tcx> GeneratorArgs<'tcx> {
#[derive(Debug, Copy, Clone, HashStable)]
pub enum UpvarArgs<'tcx> {
Closure(GenericArgsRef<'tcx>),
Generator(GenericArgsRef<'tcx>),
Coroutine(GenericArgsRef<'tcx>),
}
impl<'tcx> UpvarArgs<'tcx> {
@ -591,7 +591,7 @@ impl<'tcx> UpvarArgs<'tcx> {
pub fn upvar_tys(self) -> &'tcx List<Ty<'tcx>> {
let tupled_tys = match self {
UpvarArgs::Closure(args) => args.as_closure().tupled_upvars_ty(),
UpvarArgs::Generator(args) => args.as_generator().tupled_upvars_ty(),
UpvarArgs::Coroutine(args) => args.as_generator().tupled_upvars_ty(),
};
match tupled_tys.kind() {
@ -606,7 +606,7 @@ impl<'tcx> UpvarArgs<'tcx> {
pub fn tupled_upvars_ty(self) -> Ty<'tcx> {
match self {
UpvarArgs::Closure(args) => args.as_closure().tupled_upvars_ty(),
UpvarArgs::Generator(args) => args.as_generator().tupled_upvars_ty(),
UpvarArgs::Coroutine(args) => args.as_generator().tupled_upvars_ty(),
}
}
}
@ -2176,7 +2176,7 @@ impl<'tcx> Ty<'tcx> {
tcx.generics_of(tcx.typeck_root_def_id(def_id)).count() + 5,
"generator constructed with incorrect number of substitutions"
);
Ty::new(tcx, Generator(def_id, generator_args, movability))
Ty::new(tcx, Coroutine(def_id, generator_args, movability))
}
#[inline]
@ -2185,7 +2185,7 @@ impl<'tcx> Ty<'tcx> {
id: DefId,
args: GenericArgsRef<'tcx>,
) -> Ty<'tcx> {
Ty::new(tcx, GeneratorWitness(id, args))
Ty::new(tcx, CoroutineWitness(id, args))
}
// misc
@ -2496,7 +2496,7 @@ impl<'tcx> Ty<'tcx> {
#[inline]
pub fn is_generator(self) -> bool {
matches!(self.kind(), Generator(..))
matches!(self.kind(), Coroutine(..))
}
#[inline]
@ -2657,7 +2657,7 @@ impl<'tcx> Ty<'tcx> {
pub fn variant_range(self, tcx: TyCtxt<'tcx>) -> Option<Range<VariantIdx>> {
match self.kind() {
TyKind::Adt(adt, _) => Some(adt.variant_range()),
TyKind::Generator(def_id, args, _) => {
TyKind::Coroutine(def_id, args, _) => {
Some(args.as_generator().variant_range(*def_id, tcx))
}
_ => None,
@ -2678,7 +2678,7 @@ impl<'tcx> Ty<'tcx> {
TyKind::Adt(adt, _) if adt.is_enum() => {
Some(adt.discriminant_for_variant(tcx, variant_index))
}
TyKind::Generator(def_id, args, _) => {
TyKind::Coroutine(def_id, args, _) => {
Some(args.as_generator().discriminant_for_variant(*def_id, tcx, variant_index))
}
_ => None,
@ -2689,7 +2689,7 @@ impl<'tcx> Ty<'tcx> {
pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match self.kind() {
ty::Adt(adt, _) if adt.is_enum() => adt.repr().discr_type().to_ty(tcx),
ty::Generator(_, args, _) => args.as_generator().discr_ty(tcx),
ty::Coroutine(_, args, _) => args.as_generator().discr_ty(tcx),
ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => {
let assoc_items = tcx.associated_item_def_ids(
@ -2714,7 +2714,7 @@ impl<'tcx> Ty<'tcx> {
| ty::FnPtr(..)
| ty::Dynamic(..)
| ty::Closure(..)
| ty::GeneratorWitness(..)
| ty::CoroutineWitness(..)
| ty::Never
| ty::Tuple(_)
| ty::Error(_)
@ -2748,8 +2748,8 @@ impl<'tcx> Ty<'tcx> {
| ty::RawPtr(..)
| ty::Char
| ty::Ref(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Array(..)
| ty::Closure(..)
| ty::Never
@ -2836,8 +2836,8 @@ impl<'tcx> Ty<'tcx> {
| ty::RawPtr(..)
| ty::Char
| ty::Ref(..)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Array(..)
| ty::Closure(..)
| ty::Never
@ -2900,7 +2900,7 @@ impl<'tcx> Ty<'tcx> {
// anything with custom metadata it might be more complicated.
ty::Ref(_, _, hir::Mutability::Not) | ty::RawPtr(..) => false,
ty::Generator(..) | ty::GeneratorWitness(..) => false,
ty::Coroutine(..) | ty::CoroutineWitness(..) => false,
// Might be, but not "trivial" so just giving the safe answer.
ty::Adt(..) | ty::Closure(..) => false,
@ -2975,8 +2975,8 @@ impl<'tcx> Ty<'tcx> {
| FnPtr(_)
| Dynamic(_, _, _)
| Closure(_, _)
| Generator(_, _, _)
| GeneratorWitness(..)
| Coroutine(_, _, _)
| CoroutineWitness(..)
| Never
| Tuple(_) => true,
Error(_) | Infer(_) | Alias(_, _) | Param(_) | Bound(_, _) | Placeholder(_) => false,

View file

@ -548,7 +548,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// those are not yet phased out). The parent of the closure's
/// `DefId` will also be the context where it appears.
pub fn is_closure(self, def_id: DefId) -> bool {
matches!(self.def_kind(def_id), DefKind::Closure | DefKind::Generator)
matches!(self.def_kind(def_id), DefKind::Closure | DefKind::Coroutine)
}
/// Returns `true` if `def_id` refers to a definition that does not have its own
@ -556,7 +556,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn is_typeck_child(self, def_id: DefId) -> bool {
matches!(
self.def_kind(def_id),
DefKind::Closure | DefKind::Generator | DefKind::InlineConst
DefKind::Closure | DefKind::Coroutine | DefKind::InlineConst
)
}
@ -746,9 +746,9 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn def_kind_descr(self, def_kind: DefKind, def_id: DefId) -> &'static str {
match def_kind {
DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "method",
DefKind::Generator => match self.generator_kind(def_id).unwrap() {
rustc_hir::GeneratorKind::Async(..) => "async closure",
rustc_hir::GeneratorKind::Gen => "generator",
DefKind::Coroutine => match self.generator_kind(def_id).unwrap() {
rustc_hir::CoroutineKind::Async(..) => "async closure",
rustc_hir::CoroutineKind::Gen => "generator",
},
_ => def_kind.descr(def_id),
}
@ -763,9 +763,9 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn def_kind_descr_article(self, def_kind: DefKind, def_id: DefId) -> &'static str {
match def_kind {
DefKind::AssocFn if self.associated_item(def_id).fn_has_self_parameter => "a",
DefKind::Generator => match self.generator_kind(def_id).unwrap() {
rustc_hir::GeneratorKind::Async(..) => "an",
rustc_hir::GeneratorKind::Gen => "a",
DefKind::Coroutine => match self.generator_kind(def_id).unwrap() {
rustc_hir::CoroutineKind::Async(..) => "an",
rustc_hir::CoroutineKind::Gen => "a",
},
_ => def_kind.article(),
}
@ -888,7 +888,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx> {
t
};
if self.expand_generators {
if let ty::GeneratorWitness(def_id, args) = *t.kind() {
if let ty::CoroutineWitness(def_id, args) = *t.kind() {
t = self.expand_generator(def_id, args).unwrap_or(t);
}
}
@ -1024,8 +1024,8 @@ impl<'tcx> Ty<'tcx> {
| ty::Closure(..)
| ty::Dynamic(..)
| ty::Foreign(_)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Infer(_)
| ty::Alias(..)
| ty::Param(_)
@ -1063,8 +1063,8 @@ impl<'tcx> Ty<'tcx> {
| ty::Closure(..)
| ty::Dynamic(..)
| ty::Foreign(_)
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Infer(_)
| ty::Alias(..)
| ty::Param(_)
@ -1182,7 +1182,7 @@ impl<'tcx> Ty<'tcx> {
// Conservatively return `false` for all others...
// Anonymous function types
ty::FnDef(..) | ty::Closure(..) | ty::Dynamic(..) | ty::Generator(..) => false,
ty::FnDef(..) | ty::Closure(..) | ty::Dynamic(..) | ty::Coroutine(..) => false,
// Generic or inferred types
//
@ -1192,7 +1192,7 @@ impl<'tcx> Ty<'tcx> {
false
}
ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false,
ty::Foreign(_) | ty::CoroutineWitness(..) | ty::Error(_) => false,
}
}
@ -1287,7 +1287,7 @@ pub fn needs_drop_components<'tcx>(
| ty::FnDef(..)
| ty::FnPtr(_)
| ty::Char
| ty::GeneratorWitness(..)
| ty::CoroutineWitness(..)
| ty::RawPtr(_)
| ty::Ref(..)
| ty::Str => Ok(SmallVec::new()),
@ -1327,7 +1327,7 @@ pub fn needs_drop_components<'tcx>(
| ty::Placeholder(..)
| ty::Infer(_)
| ty::Closure(..)
| ty::Generator(..) => Ok(smallvec![ty]),
| ty::Coroutine(..) => Ok(smallvec![ty]),
}
}
@ -1358,7 +1358,7 @@ pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool {
// Not trivial because they have components, and instead of looking inside,
// we'll just perform trait selection.
ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) | ty::Adt(..) => false,
ty::Closure(..) | ty::Coroutine(..) | ty::CoroutineWitness(..) | ty::Adt(..) => false,
ty::Array(ty, _) | ty::Slice(ty) => is_trivially_const_drop(ty),

View file

@ -189,8 +189,8 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
}
ty::Adt(_, args)
| ty::Closure(_, args)
| ty::Generator(_, args, _)
| ty::GeneratorWitness(_, args)
| ty::Coroutine(_, args, _)
| ty::CoroutineWitness(_, args)
| ty::FnDef(_, args) => {
stack.extend(args.iter().rev());
}