about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-19 21:46:28 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-10-20 21:14:01 +0000
commite96ce20b34789d29e925425da6cf138927b80a79 (patch)
tree4032e01ddd5137d1ee98b69277953f2962bbf14b /compiler/rustc_ty_utils/src
parent60956837cfbf22bd8edd80f57a856e141f7deb8c (diff)
downloadrust-e96ce20b34789d29e925425da6cf138927b80a79.tar.gz
rust-e96ce20b34789d29e925425da6cf138927b80a79.zip
s/generator/coroutine/
Diffstat (limited to 'compiler/rustc_ty_utils/src')
-rw-r--r--compiler/rustc_ty_utils/src/abi.rs10
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs12
-rw-r--r--compiler/rustc_ty_utils/src/layout.rs48
-rw-r--r--compiler/rustc_ty_utils/src/needs_drop.rs4
-rw-r--r--compiler/rustc_ty_utils/src/opaque_types.rs2
5 files changed, 38 insertions, 38 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs
index f6eec38af7b..fcf6626bbf0 100644
--- a/compiler/rustc_ty_utils/src/abi.rs
+++ b/compiler/rustc_ty_utils/src/abi.rs
@@ -98,7 +98,7 @@ fn fn_sig_for_fn_abi<'tcx>(
             )
         }
         ty::Coroutine(did, args, _) => {
-            let sig = args.as_generator().poly_sig();
+            let sig = args.as_coroutine().poly_sig();
 
             let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
                 sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
@@ -116,11 +116,11 @@ fn fn_sig_for_fn_abi<'tcx>(
             let env_ty = Ty::new_adt(tcx, pin_adt_ref, pin_args);
 
             let sig = sig.skip_binder();
-            // The `FnSig` and the `ret_ty` here is for a generators main
+            // The `FnSig` and the `ret_ty` here is for a coroutines main
             // `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) {
+            // have an ordinary coroutine, or the `Future::poll(...) -> Poll`
+            // function in case this is a special coroutine backing an async construct.
+            let (resume_ty, ret_ty) = if tcx.coroutine_is_async(did) {
                 // The signature should be `Future::poll(_, &mut Context<'_>) -> Poll<Output>`
                 let poll_did = tcx.require_lang_item(LangItem::Poll, None);
                 let poll_adt_ref = tcx.adt_def(poll_did);
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 7f3e2cefd02..0e9d79c15c3 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -246,12 +246,12 @@ fn resolve_associated_item<'tcx>(
                     })
                 }
             } else if Some(trait_ref.def_id) == lang_items.future_trait() {
-                let ty::Coroutine(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
+                let ty::Coroutine(coroutine_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
                     bug!()
                 };
                 if Some(trait_item_id) == tcx.lang_items().future_poll_fn() {
                     // `Future::poll` is generated by the compiler.
-                    Some(Instance { def: ty::InstanceDef::Item(generator_def_id), args: args })
+                    Some(Instance { def: ty::InstanceDef::Item(coroutine_def_id), args: args })
                 } else {
                     // All other methods are default methods of the `Future` trait.
                     // (this assumes that `ImplSource::Builtin` is only used for methods on `Future`)
@@ -259,7 +259,7 @@ 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::Coroutine(generator_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
+                let ty::Coroutine(coroutine_def_id, args, _) = *rcvr_args.type_at(0).kind() else {
                     bug!()
                 };
                 if cfg!(debug_assertions) && tcx.item_name(trait_item_id) != sym::resume {
@@ -268,12 +268,12 @@ fn resolve_associated_item<'tcx>(
                     // `InstanceDef::Item` pointing to a trait default method body if
                     // it is given a default implementation by the trait.
                     span_bug!(
-                        tcx.def_span(generator_def_id),
-                        "no definition for `{trait_ref}::{}` for built-in generator type",
+                        tcx.def_span(coroutine_def_id),
+                        "no definition for `{trait_ref}::{}` for built-in coroutine type",
                         tcx.item_name(trait_item_id)
                     )
                 }
-                Some(Instance { def: ty::InstanceDef::Item(generator_def_id), args })
+                Some(Instance { def: ty::InstanceDef::Item(coroutine_def_id), args })
             } else if tcx.fn_trait_kind_from_def_id(trait_ref.def_id).is_some() {
                 // FIXME: This doesn't check for malformed libcore that defines, e.g.,
                 // `trait Fn { fn call_once(&self) { .. } }`. This is mostly for extension
diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs
index 8cb4162563e..283862b5e1c 100644
--- a/compiler/rustc_ty_utils/src/layout.rs
+++ b/compiler/rustc_ty_utils/src/layout.rs
@@ -314,7 +314,7 @@ fn layout_of_uncached<'tcx>(
             tcx.mk_layout(unit)
         }
 
-        ty::Coroutine(def_id, args, _) => generator_layout(cx, ty, def_id, args)?,
+        ty::Coroutine(def_id, args, _) => coroutine_layout(cx, ty, def_id, args)?,
 
         ty::Closure(_, ref args) => {
             let tys = args.as_closure().upvar_tys();
@@ -593,7 +593,7 @@ enum SavedLocalEligibility {
     Ineligible(Option<FieldIdx>),
 }
 
-// When laying out generators, we divide our saved local fields into two
+// When laying out coroutines, we divide our saved local fields into two
 // categories: overlap-eligible and overlap-ineligible.
 //
 // Those fields which are ineligible for overlap go in a "prefix" at the
@@ -613,7 +613,7 @@ enum SavedLocalEligibility {
 // of any variant.
 
 /// Compute the eligibility and assignment of each local.
-fn generator_saved_local_eligibility(
+fn coroutine_saved_local_eligibility(
     info: &CoroutineLayout<'_>,
 ) -> (BitSet<CoroutineSavedLocal>, IndexVec<CoroutineSavedLocal, SavedLocalEligibility>) {
     use SavedLocalEligibility::*;
@@ -622,7 +622,7 @@ fn generator_saved_local_eligibility(
         IndexVec::from_elem(Unassigned, &info.field_tys);
 
     // The saved locals not eligible for overlap. These will get
-    // "promoted" to the prefix of our generator.
+    // "promoted" to the prefix of our coroutine.
     let mut ineligible_locals = BitSet::new_empty(info.field_tys.len());
 
     // Figure out which of our saved locals are fields in only
@@ -660,7 +660,7 @@ fn generator_saved_local_eligibility(
 
         for local_b in info.storage_conflicts.iter(local_a) {
             // local_a and local_b are storage live at the same time, therefore they
-            // cannot overlap in the generator layout. The only way to guarantee
+            // cannot overlap in the coroutine layout. The only way to guarantee
             // this is if they are in the same variant, or one is ineligible
             // (which means it is stored in every variant).
             if ineligible_locals.contains(local_b) || assignments[local_a] == assignments[local_b] {
@@ -705,13 +705,13 @@ fn generator_saved_local_eligibility(
             assignments[local] = Ineligible(Some(FieldIdx::from_usize(idx)));
         }
     }
-    debug!("generator saved local assignments: {:?}", assignments);
+    debug!("coroutine saved local assignments: {:?}", assignments);
 
     (ineligible_locals, assignments)
 }
 
-/// Compute the full generator layout.
-fn generator_layout<'tcx>(
+/// Compute the full coroutine layout.
+fn coroutine_layout<'tcx>(
     cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
     ty: Ty<'tcx>,
     def_id: hir::def_id::DefId,
@@ -721,15 +721,15 @@ fn generator_layout<'tcx>(
     let tcx = cx.tcx;
     let subst_field = |ty: Ty<'tcx>| EarlyBinder::bind(ty).instantiate(tcx, args);
 
-    let Some(info) = tcx.generator_layout(def_id) else {
+    let Some(info) = tcx.coroutine_layout(def_id) else {
         return Err(error(cx, LayoutError::Unknown(ty)));
     };
-    let (ineligible_locals, assignments) = generator_saved_local_eligibility(&info);
+    let (ineligible_locals, assignments) = coroutine_saved_local_eligibility(&info);
 
     // Build a prefix layout, including "promoting" all ineligible
     // locals as part of the prefix. We compute the layout of all of
     // these fields at once to get optimal packing.
-    let tag_index = args.as_generator().prefix_tys().len();
+    let tag_index = args.as_coroutine().prefix_tys().len();
 
     // `info.variant_fields` already accounts for the reserved variants, so no need to add them.
     let max_discr = (info.variant_fields.len() - 1) as u128;
@@ -746,7 +746,7 @@ fn generator_layout<'tcx>(
         .map(|ty| Ty::new_maybe_uninit(tcx, ty))
         .map(|ty| Ok(cx.layout_of(ty)?.layout));
     let prefix_layouts = args
-        .as_generator()
+        .as_coroutine()
         .prefix_tys()
         .iter()
         .map(|ty| Ok(cx.layout_of(ty)?.layout))
@@ -907,7 +907,7 @@ fn generator_layout<'tcx>(
         max_repr_align: None,
         unadjusted_abi_align: align.abi,
     });
-    debug!("generator layout ({:?}): {:#?}", ty, layout);
+    debug!("coroutine layout ({:?}): {:#?}", ty, layout);
     Ok(layout)
 }
 
@@ -957,10 +957,10 @@ fn record_layout_for_printing_outlined<'tcx>(
         }
 
         ty::Coroutine(def_id, args, _) => {
-            debug!("print-type-size t: `{:?}` record generator", layout.ty);
+            debug!("print-type-size t: `{:?}` record coroutine", layout.ty);
             // 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);
+                variant_info_for_coroutine(cx, layout, def_id, args);
             record(DataTypeKind::Coroutine, false, opt_discr_size, variant_infos);
         }
 
@@ -1046,7 +1046,7 @@ fn variant_info_for_adt<'tcx>(
     }
 }
 
-fn variant_info_for_generator<'tcx>(
+fn variant_info_for_coroutine<'tcx>(
     cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
     layout: TyAndLayout<'tcx>,
     def_id: DefId,
@@ -1056,12 +1056,12 @@ fn variant_info_for_generator<'tcx>(
         return (vec![], None);
     };
 
-    let generator = cx.tcx.optimized_mir(def_id).generator_layout().unwrap();
+    let coroutine = cx.tcx.optimized_mir(def_id).coroutine_layout().unwrap();
     let upvar_names = cx.tcx.closure_saved_names_of_captured_variables(def_id);
 
     let mut upvars_size = Size::ZERO;
     let upvar_fields: Vec<_> = args
-        .as_generator()
+        .as_coroutine()
         .upvar_tys()
         .iter()
         .zip(upvar_names)
@@ -1080,7 +1080,7 @@ fn variant_info_for_generator<'tcx>(
         })
         .collect();
 
-    let mut variant_infos: Vec<_> = generator
+    let mut variant_infos: Vec<_> = coroutine
         .variant_fields
         .iter_enumerated()
         .map(|(variant_idx, variant_def)| {
@@ -1096,8 +1096,8 @@ fn variant_info_for_generator<'tcx>(
                     variant_size = variant_size.max(offset + field_layout.size);
                     FieldInfo {
                         kind: FieldKind::CoroutineLocal,
-                        name: generator.field_names[*local].unwrap_or(Symbol::intern(&format!(
-                            ".generator_field{}",
+                        name: coroutine.field_names[*local].unwrap_or(Symbol::intern(&format!(
+                            ".coroutine_field{}",
                             local.as_usize()
                         ))),
                         offset: offset.bytes(),
@@ -1115,8 +1115,8 @@ fn variant_info_for_generator<'tcx>(
 
             // This `if` deserves some explanation.
             //
-            // The layout code has a choice of where to place the discriminant of this generator.
-            // If the discriminant of the generator is placed early in the layout (before the
+            // The layout code has a choice of where to place the discriminant of this coroutine.
+            // If the discriminant of the coroutine is placed early in the layout (before the
             // variant's own fields), then it'll implicitly be counted towards the size of the
             // variant, since we use the maximum offset to calculate size.
             //    (side-note: I know this is a bit problematic given upvars placement, etc).
@@ -1147,7 +1147,7 @@ fn variant_info_for_generator<'tcx>(
 
     // The first three variants are hardcoded to be `UNRESUMED`, `RETURNED` and `POISONED`.
     // We will move the `RETURNED` and `POISONED` elements to the end so we
-    // are left with a sorting order according to the generators yield points:
+    // are left with a sorting order according to the coroutines yield points:
     // First `Unresumed`, then the `SuspendN` followed by `Returned` and `Panicked` (POISONED).
     let end_states = variant_infos.drain(1..=2);
     let end_states: Vec<_> = end_states.collect();
diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs
index c2190118b2e..08127304741 100644
--- a/compiler/rustc_ty_utils/src/needs_drop.rs
+++ b/compiler/rustc_ty_utils/src/needs_drop.rs
@@ -130,9 +130,9 @@ where
 
             for component in components {
                 match *component.kind() {
-                    // The information required to determine whether a generator has drop is
+                    // The information required to determine whether a coroutine 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.
+                    // To avoid cycles, we consider that coroutines always require drop.
                     ty::Coroutine(..) => {
                         return Some(Err(AlwaysRequiresDrop));
                     }
diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs
index a297f9af56a..0010570e7b3 100644
--- a/compiler/rustc_ty_utils/src/opaque_types.rs
+++ b/compiler/rustc_ty_utils/src/opaque_types.rs
@@ -322,7 +322,7 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
         | DefKind::LifetimeParam
         | DefKind::GlobalAsm
         | DefKind::Impl { .. } => {}
-        // Closures and generators are type checked with their parent, so there is no difference here.
+        // Closures and coroutines are type checked with their parent, so there is no difference here.
         DefKind::Closure | DefKind::Coroutine | DefKind::InlineConst => {
             return tcx.opaque_types_defined_by(tcx.local_parent(item));
         }