Remove movability from TyKind::Coroutine

This commit is contained in:
Michael Goulet 2023-12-21 01:52:10 +00:00
parent f4d794ea0b
commit fcb42b42d6
84 changed files with 212 additions and 220 deletions

View file

@ -97,7 +97,7 @@ fn fn_sig_for_fn_abi<'tcx>(
bound_vars,
)
}
ty::Coroutine(did, args, _) => {
ty::Coroutine(did, args) => {
let coroutine_kind = tcx.coroutine_kind(did).unwrap();
let sig = args.as_coroutine().sig();

View file

@ -246,7 +246,7 @@ fn resolve_associated_item<'tcx>(
})
}
} else if Some(trait_ref.def_id) == lang_items.future_trait() {
let ty::Coroutine(coroutine_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() {
@ -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.iterator_trait() {
let ty::Coroutine(coroutine_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().next_fn() {
@ -272,7 +272,7 @@ fn resolve_associated_item<'tcx>(
Some(Instance::new(trait_item_id, rcvr_args))
}
} else if Some(trait_ref.def_id) == lang_items.async_iterator_trait() {
let ty::Coroutine(coroutine_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!()
};
@ -287,7 +287,7 @@ fn resolve_associated_item<'tcx>(
// `AsyncIterator::poll_next` is generated by the compiler.
Some(Instance { def: ty::InstanceDef::Item(coroutine_def_id), args })
} else if Some(trait_ref.def_id) == lang_items.coroutine_trait() {
let ty::Coroutine(coroutine_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 {

View file

@ -316,7 +316,7 @@ fn layout_of_uncached<'tcx>(
tcx.mk_layout(unit)
}
ty::Coroutine(def_id, args, _) => coroutine_layout(cx, ty, def_id, args)?,
ty::Coroutine(def_id, args) => coroutine_layout(cx, ty, def_id, args)?,
ty::Closure(_, args) => {
let tys = args.as_closure().upvar_tys();
@ -961,7 +961,7 @@ fn record_layout_for_printing<'tcx>(cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, layout: T
record(adt_kind.into(), adt_packed, opt_discr_size, variant_infos);
}
ty::Coroutine(def_id, args, _) => {
ty::Coroutine(def_id, args) => {
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) =

View file

@ -145,7 +145,7 @@ where
// for the coroutine witness and check whether any of the contained types
// need to be dropped, and only require the captured types to be live
// if they do.
ty::Coroutine(_, args, _) => {
ty::Coroutine(_, args) => {
if self.reveal_coroutine_witnesses {
queue_type(self, args.as_coroutine().witness());
} else {

View file

@ -307,6 +307,16 @@ fn asyncness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Asyncness {
})
}
fn movability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Movability {
let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(closure), .. }) =
tcx.hir_node_by_def_id(def_id)
else {
bug!("expected query `movability` only called on coroutine def id");
};
closure.movability.expect("expected coroutine to have movability")
}
fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> BitSet<u32> {
let def = tcx.adt_def(def_id);
let num_params = tcx.generics_of(def_id).count();
@ -354,6 +364,7 @@ fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> BitSet<u32
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers {
asyncness,
movability,
adt_sized_constraint,
param_env,
param_env_reveal_all_normalized,