s/generator/coroutine/
This commit is contained in:
parent
60956837cf
commit
e96ce20b34
468 changed files with 2201 additions and 2197 deletions
|
@ -291,7 +291,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
|
||||
let opaque_ty = Ty::new_opaque(tcx, def_id.to_def_id(), args);
|
||||
|
||||
// `ReErased` regions appear in the "parent_args" of closures/generators.
|
||||
// `ReErased` regions appear in the "parent_args" of closures/coroutines.
|
||||
// We're ignoring them here and replacing them with fresh region variables.
|
||||
// See tests in ui/type-alias-impl-trait/closure_{parent_args,wf_outlives}.rs.
|
||||
//
|
||||
|
@ -1446,11 +1446,11 @@ fn opaque_type_cycle_error(
|
|||
{
|
||||
label_match(capture.place.ty(), capture.get_path_span(tcx));
|
||||
}
|
||||
// Label any generator locals that capture the opaque
|
||||
// Label any coroutine locals that capture the opaque
|
||||
if let DefKind::Coroutine = tcx.def_kind(closure_def_id)
|
||||
&& let Some(generator_layout) = tcx.mir_generator_witnesses(closure_def_id)
|
||||
&& let Some(coroutine_layout) = tcx.mir_coroutine_witnesses(closure_def_id)
|
||||
{
|
||||
for interior_ty in &generator_layout.field_tys {
|
||||
for interior_ty in &coroutine_layout.field_tys {
|
||||
label_match(interior_ty.ty, interior_ty.source_info.span);
|
||||
}
|
||||
}
|
||||
|
@ -1464,14 +1464,14 @@ fn opaque_type_cycle_error(
|
|||
err.emit()
|
||||
}
|
||||
|
||||
pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
pub(super) fn check_coroutine_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Coroutine));
|
||||
|
||||
let typeck = tcx.typeck(def_id);
|
||||
let param_env = tcx.param_env(def_id);
|
||||
|
||||
let generator_interior_predicates = &typeck.generator_interior_predicates[&def_id];
|
||||
debug!(?generator_interior_predicates);
|
||||
let coroutine_interior_predicates = &typeck.coroutine_interior_predicates[&def_id];
|
||||
debug!(?coroutine_interior_predicates);
|
||||
|
||||
let infcx = tcx
|
||||
.infer_ctxt()
|
||||
|
@ -1483,15 +1483,15 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
.build();
|
||||
|
||||
let mut fulfillment_cx = <dyn TraitEngine<'_>>::new(&infcx);
|
||||
for (predicate, cause) in generator_interior_predicates {
|
||||
for (predicate, cause) in coroutine_interior_predicates {
|
||||
let obligation = Obligation::new(tcx, cause.clone(), param_env, *predicate);
|
||||
fulfillment_cx.register_predicate_obligation(&infcx, obligation);
|
||||
}
|
||||
|
||||
if (tcx.features().unsized_locals || tcx.features().unsized_fn_params)
|
||||
&& let Some(generator) = tcx.mir_generator_witnesses(def_id)
|
||||
&& let Some(coroutine) = tcx.mir_coroutine_witnesses(def_id)
|
||||
{
|
||||
for field_ty in generator.field_tys.iter() {
|
||||
for field_ty in coroutine.field_tys.iter() {
|
||||
fulfillment_cx.register_bound(
|
||||
&infcx,
|
||||
param_env,
|
||||
|
|
|
@ -114,7 +114,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
region_scope_tree,
|
||||
collect_return_position_impl_trait_in_trait_tys,
|
||||
compare_impl_const: compare_impl_item::compare_impl_const_raw,
|
||||
check_generator_obligations: check::check_generator_obligations,
|
||||
check_coroutine_obligations: check::check_coroutine_obligations,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
|
|
@ -598,7 +598,7 @@ fn resolve_local<'tcx>(
|
|||
}
|
||||
|
||||
// Make sure we visit the initializer first, so expr_and_pat_count remains correct.
|
||||
// The correct order, as shared between generator_interior, drop_ranges and intravisitor,
|
||||
// The correct order, as shared between coroutine_interior, drop_ranges and intravisitor,
|
||||
// is to walk initializer, followed by pattern bindings, finally followed by the `else` block.
|
||||
if let Some(expr) = init {
|
||||
visitor.visit_expr(expr);
|
||||
|
@ -825,7 +825,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
|
|||
resolve_local(self, None, Some(&body.value));
|
||||
}
|
||||
|
||||
if body.generator_kind.is_some() {
|
||||
if body.coroutine_kind.is_some() {
|
||||
self.scope_tree.body_expr_count.insert(body_id, self.expr_and_pat_count);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
fn_sig,
|
||||
impl_trait_ref,
|
||||
impl_polarity,
|
||||
generator_kind,
|
||||
coroutine_kind,
|
||||
collect_mod_item_types,
|
||||
is_type_alias_impl_trait,
|
||||
..*providers
|
||||
|
@ -1548,12 +1548,12 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
|||
fty
|
||||
}
|
||||
|
||||
fn generator_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<hir::CoroutineKind> {
|
||||
fn coroutine_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<hir::CoroutineKind> {
|
||||
match tcx.hir().get_by_def_id(def_id) {
|
||||
Node::Expr(&rustc_hir::Expr {
|
||||
kind: rustc_hir::ExprKind::Closure(&rustc_hir::Closure { body, .. }),
|
||||
..
|
||||
}) => tcx.hir().body(body).generator_kind(),
|
||||
}) => tcx.hir().body(body).coroutine_kind(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue