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

@ -313,7 +313,7 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
// generic functions from consideration as well.
if !matches!(
kind,
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine
) {
return None;
}

View file

@ -460,7 +460,7 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D
}
ty::FnDef(..) | ty::FnPtr(_) => build_subroutine_type_di_node(cx, unique_type_id),
ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id),
ty::Generator(..) => enums::build_generator_di_node(cx, unique_type_id),
ty::Coroutine(..) => enums::build_generator_di_node(cx, unique_type_id),
ty::Adt(def, ..) => match def.adt_kind() {
AdtKind::Struct => build_struct_type_di_node(cx, unique_type_id),
AdtKind::Union => build_union_type_di_node(cx, unique_type_id),
@ -1034,7 +1034,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
closure_or_generator_di_node: &'ll DIType,
) -> SmallVec<&'ll DIType> {
let (&def_id, up_var_tys) = match closure_or_generator_ty.kind() {
ty::Generator(def_id, args, _) => (def_id, args.as_generator().prefix_tys()),
ty::Coroutine(def_id, args, _) => (def_id, args.as_generator().prefix_tys()),
ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()),
_ => {
bug!(

View file

@ -12,7 +12,7 @@ use rustc_middle::{
ty::{
self,
layout::{LayoutOf, TyAndLayout},
AdtDef, GeneratorArgs, Ty,
AdtDef, CoroutineArgs, Ty,
},
};
use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants};
@ -674,7 +674,7 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
};
let (generator_def_id, generator_args) = match generator_type_and_layout.ty.kind() {
&ty::Generator(def_id, args, _) => (def_id, args.as_generator()),
&ty::Coroutine(def_id, args, _) => (def_id, args.as_generator()),
_ => unreachable!(),
};
@ -691,7 +691,7 @@ fn build_union_fields_for_direct_tag_generator<'ll, 'tcx>(
generator_type_di_node,
variant_range
.clone()
.map(|variant_index| (variant_index, GeneratorArgs::variant_name(variant_index))),
.map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))),
);
let discriminants: IndexVec<VariantIdx, DiscrResult> = {

View file

@ -6,11 +6,11 @@ use rustc_hir::def::CtorKind;
use rustc_index::IndexSlice;
use rustc_middle::{
bug,
mir::GeneratorLayout,
mir::CoroutineLayout,
ty::{
self,
layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout},
AdtDef, GeneratorArgs, Ty, VariantDef,
AdtDef, CoroutineArgs, Ty, VariantDef,
},
};
use rustc_span::Symbol;
@ -107,7 +107,7 @@ fn tag_base_type<'ll, 'tcx>(
enum_type_and_layout: TyAndLayout<'tcx>,
) -> Ty<'tcx> {
debug_assert!(match enum_type_and_layout.ty.kind() {
ty::Generator(..) => true,
ty::Coroutine(..) => true,
ty::Adt(adt_def, _) => adt_def.is_enum(),
_ => false,
});
@ -322,10 +322,10 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
variant_index: VariantIdx,
generator_type_and_layout: TyAndLayout<'tcx>,
generator_type_di_node: &'ll DIType,
generator_layout: &GeneratorLayout<'tcx>,
generator_layout: &CoroutineLayout<'tcx>,
common_upvar_names: &IndexSlice<FieldIdx, Symbol>,
) -> &'ll DIType {
let variant_name = GeneratorArgs::variant_name(variant_index);
let variant_name = CoroutineArgs::variant_name(variant_index);
let unique_type_id = UniqueTypeId::for_enum_variant_struct_type(
cx.tcx,
generator_type_and_layout.ty,
@ -335,7 +335,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
let variant_layout = generator_type_and_layout.for_variant(cx, variant_index);
let generator_args = match generator_type_and_layout.ty.kind() {
ty::Generator(_, args, _) => args.as_generator(),
ty::Coroutine(_, args, _) => args.as_generator(),
_ => unreachable!(),
};

View file

@ -132,7 +132,7 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
let generator_type = unique_type_id.expect_ty();
let &ty::Generator(generator_def_id, _, _) = generator_type.kind() else {
let &ty::Coroutine(generator_def_id, _, _) = generator_type.kind() else {
bug!("build_generator_di_node() called with non-generator type: `{:?}`", generator_type)
};
@ -175,7 +175,7 @@ pub(super) fn build_generator_di_node<'ll, 'tcx>(
.indices()
.map(|variant_index| {
// FIXME: This is problematic because just a number is not a valid identifier.
// GeneratorArgs::variant_name(variant_index), would be consistent
// CoroutineArgs::variant_name(variant_index), would be consistent
// with enums?
let variant_name = format!("{}", variant_index.as_usize()).into();
@ -310,7 +310,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
enum_or_generator_type_di_node: &'ll DIType,
) -> Option<&'ll DIType> {
let tag_name = match enum_or_generator_type_and_layout.ty.kind() {
ty::Generator(..) => "__state",
ty::Coroutine(..) => "__state",
_ => "",
};

View file

@ -42,7 +42,7 @@ fn uncached_llvm_type<'a, 'tcx>(
// FIXME(eddyb) producing readable type names for trait objects can result
// in problematically distinct types due to HRTB and subtyping (see #47638).
// ty::Dynamic(..) |
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str
// For performance reasons we use names only when emitting LLVM IR.
if !cx.sess().fewer_names() =>
{
@ -54,10 +54,10 @@ fn uncached_llvm_type<'a, 'tcx>(
write!(&mut name, "::{}", def.variant(index).name).unwrap();
}
}
if let (&ty::Generator(_, _, _), &Variants::Single { index }) =
if let (&ty::Coroutine(_, _, _), &Variants::Single { index }) =
(layout.ty.kind(), &layout.variants)
{
write!(&mut name, "::{}", ty::GeneratorArgs::variant_name(index)).unwrap();
write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap();
}
Some(name)
}