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

@ -97,7 +97,7 @@ fn fn_sig_for_fn_abi<'tcx>(
bound_vars,
)
}
ty::Generator(did, args, _) => {
ty::Coroutine(did, args, _) => {
let sig = args.as_generator().poly_sig();
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
@ -117,7 +117,7 @@ fn fn_sig_for_fn_abi<'tcx>(
let sig = sig.skip_binder();
// The `FnSig` and the `ret_ty` here is for a generators main
// `Generator::resume(...) -> GeneratorState` function in case we
// `Coroutine::resume(...) -> CoroutineState` function in case we
// have an ordinary generator, or the `Future::poll(...) -> Poll`
// function in case this is a special generator backing an async construct.
let (resume_ty, ret_ty) = if tcx.generator_is_async(did) {
@ -143,8 +143,8 @@ fn fn_sig_for_fn_abi<'tcx>(
(context_mut_ref, ret_ty)
} else {
// The signature should be `Generator::resume(_, Resume) -> GeneratorState<Yield, Return>`
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
// The signature should be `Coroutine::resume(_, Resume) -> CoroutineState<Yield, Return>`
let state_did = tcx.require_lang_item(LangItem::CoroutineState, None);
let state_adt_ref = tcx.adt_def(state_did);
let state_args = tcx.mk_args(&[sig.yield_ty.into(), sig.return_ty.into()]);
let ret_ty = Ty::new_adt(tcx, state_adt_ref, state_args);

View file

@ -157,7 +157,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::Generator => ty::List::empty(),
| DefKind::Coroutine => ty::List::empty(),
}
}

View file

@ -38,7 +38,7 @@ fn resolve_instance<'tcx>(
debug!(" => nontrivial drop glue");
match *ty.kind() {
ty::Closure(..)
| ty::Generator(..)
| ty::Coroutine(..)
| ty::Tuple(..)
| ty::Adt(..)
| ty::Dynamic(..)
@ -212,8 +212,8 @@ fn resolve_associated_item<'tcx>(
let is_copy = self_ty.is_copy_modulo_regions(tcx, param_env);
match self_ty.kind() {
_ if is_copy => (),
ty::Generator(..)
| ty::GeneratorWitness(..)
ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Closure(..)
| ty::Tuple(..) => {}
_ => return Ok(None),
@ -246,7 +246,7 @@ fn resolve_associated_item<'tcx>(
})
}
} else if Some(trait_ref.def_id) == lang_items.future_trait() {
let ty::Generator(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
let ty::Coroutine(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
bug!()
};
if Some(trait_item_id) == tcx.lang_items().future_poll_fn() {
@ -259,11 +259,11 @@ fn resolve_associated_item<'tcx>(
Some(Instance::new(trait_item_id, rcvr_args))
}
} else if Some(trait_ref.def_id) == lang_items.gen_trait() {
let ty::Generator(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
let ty::Coroutine(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
bug!()
};
if cfg!(debug_assertions) && tcx.item_name(trait_item_id) != sym::resume {
// For compiler developers who'd like to add new items to `Generator`,
// For compiler developers who'd like to add new items to `Coroutine`,
// you either need to generate a shim body, or perhaps return
// `InstanceDef::Item` pointing to a trait default method body if
// it is given a default implementation by the trait.

View file

@ -2,7 +2,7 @@ use hir::def_id::DefId;
use rustc_hir as hir;
use rustc_index::bit_set::BitSet;
use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::mir::{GeneratorLayout, GeneratorSavedLocal};
use rustc_middle::mir::{CoroutineLayout, CoroutineSavedLocal};
use rustc_middle::query::Providers;
use rustc_middle::ty::layout::{
IntegerExt, LayoutCx, LayoutError, LayoutOf, TyAndLayout, MAX_SIMD_LANES,
@ -314,7 +314,7 @@ fn layout_of_uncached<'tcx>(
tcx.mk_layout(unit)
}
ty::Generator(def_id, args, _) => generator_layout(cx, ty, def_id, args)?,
ty::Coroutine(def_id, args, _) => generator_layout(cx, ty, def_id, args)?,
ty::Closure(_, ref args) => {
let tys = args.as_closure().upvar_tys();
@ -575,7 +575,7 @@ fn layout_of_uncached<'tcx>(
return Err(error(cx, LayoutError::Unknown(ty)));
}
ty::Bound(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => {
ty::Bound(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => {
bug!("Layout::compute: unexpected type `{}`", ty)
}
@ -585,7 +585,7 @@ fn layout_of_uncached<'tcx>(
})
}
/// Overlap eligibility and variant assignment for each GeneratorSavedLocal.
/// Overlap eligibility and variant assignment for each CoroutineSavedLocal.
#[derive(Clone, Debug, PartialEq)]
enum SavedLocalEligibility {
Unassigned,
@ -614,11 +614,11 @@ enum SavedLocalEligibility {
/// Compute the eligibility and assignment of each local.
fn generator_saved_local_eligibility(
info: &GeneratorLayout<'_>,
) -> (BitSet<GeneratorSavedLocal>, IndexVec<GeneratorSavedLocal, SavedLocalEligibility>) {
info: &CoroutineLayout<'_>,
) -> (BitSet<CoroutineSavedLocal>, IndexVec<CoroutineSavedLocal, SavedLocalEligibility>) {
use SavedLocalEligibility::*;
let mut assignments: IndexVec<GeneratorSavedLocal, SavedLocalEligibility> =
let mut assignments: IndexVec<CoroutineSavedLocal, SavedLocalEligibility> =
IndexVec::from_elem(Unassigned, &info.field_tys);
// The saved locals not eligible for overlap. These will get
@ -766,7 +766,7 @@ fn generator_layout<'tcx>(
// Split the prefix layout into the "outer" fields (upvars and
// discriminant) and the "promoted" fields. Promoted fields will
// get included in each variant that requested them in
// GeneratorLayout.
// CoroutineLayout.
debug!("prefix = {:#?}", prefix);
let (outer_fields, promoted_offsets, promoted_memory_index) = match prefix.fields {
FieldsShape::Arbitrary { mut offsets, memory_index } => {
@ -833,7 +833,7 @@ fn generator_layout<'tcx>(
};
// Now, stitch the promoted and variant-only fields back together in
// the order they are mentioned by our GeneratorLayout.
// the order they are mentioned by our CoroutineLayout.
// Because we only use some subset (that can differ between variants)
// of the promoted fields, we can't just pick those elements of the
// `promoted_memory_index` (as we'd end up with gaps).
@ -956,12 +956,12 @@ fn record_layout_for_printing_outlined<'tcx>(
record(adt_kind.into(), adt_packed, opt_discr_size, variant_infos);
}
ty::Generator(def_id, args, _) => {
ty::Coroutine(def_id, args, _) => {
debug!("print-type-size t: `{:?}` record generator", layout.ty);
// Generators always have a begin/poisoned/end state with additional suspend points
// Coroutines always have a begin/poisoned/end state with additional suspend points
let (variant_infos, opt_discr_size) =
variant_info_for_generator(cx, layout, def_id, args);
record(DataTypeKind::Generator, false, opt_discr_size, variant_infos);
record(DataTypeKind::Coroutine, false, opt_discr_size, variant_infos);
}
ty::Closure(..) => {
@ -1095,7 +1095,7 @@ fn variant_info_for_generator<'tcx>(
// The struct is as large as the last field's end
variant_size = variant_size.max(offset + field_layout.size);
FieldInfo {
kind: FieldKind::GeneratorLocal,
kind: FieldKind::CoroutineLocal,
name: generator.field_names[*local].unwrap_or(Symbol::intern(&format!(
".generator_field{}",
local.as_usize()
@ -1136,7 +1136,7 @@ fn variant_info_for_generator<'tcx>(
}
VariantInfo {
name: Some(Symbol::intern(&ty::GeneratorArgs::variant_name(variant_idx))),
name: Some(Symbol::intern(&ty::CoroutineArgs::variant_name(variant_idx))),
kind: SizeKind::Exact,
size: variant_size.bytes(),
align: variant_layout.align.abi.bytes(),

View file

@ -133,7 +133,7 @@ where
// The information required to determine whether a generator has drop is
// computed on MIR, while this very method is used to build MIR.
// To avoid cycles, we consider that generators always require drop.
ty::Generator(..) => {
ty::Coroutine(..) => {
return Some(Err(AlwaysRequiresDrop));
}
@ -191,7 +191,7 @@ where
| ty::FnPtr(..)
| ty::Tuple(_)
| ty::Bound(..)
| ty::GeneratorWitness(..)
| ty::CoroutineWitness(..)
| ty::Never
| ty::Infer(_)
| ty::Error(_) => {

View file

@ -323,7 +323,7 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
| DefKind::GlobalAsm
| DefKind::Impl { .. } => {}
// Closures and generators are type checked with their parent, so there is no difference here.
DefKind::Closure | DefKind::Generator | DefKind::InlineConst => {
DefKind::Closure | DefKind::Coroutine | DefKind::InlineConst => {
return tcx.opaque_types_defined_by(tcx.local_parent(item));
}
}

View file

@ -18,9 +18,9 @@ fn sized_constraint_for_ty<'tcx>(
let result = match ty.kind() {
Bool | Char | Int(..) | Uint(..) | Float(..) | RawPtr(..) | Ref(..) | FnDef(..)
| FnPtr(_) | Array(..) | Closure(..) | Generator(..) | Never => vec![],
| FnPtr(_) | Array(..) | Closure(..) | Coroutine(..) | Never => vec![],
Str | Dynamic(..) | Slice(_) | Foreign(..) | Error(_) | GeneratorWitness(..) => {
Str | Dynamic(..) | Slice(_) | Foreign(..) | Error(_) | CoroutineWitness(..) => {
// these are never sized - return the target type
vec![ty]
}