Encode opt_rpitit_info for associated types

This commit is contained in:
Michael Goulet 2023-03-13 17:22:16 +00:00
parent 669e751639
commit 0404e264a2
5 changed files with 16 additions and 8 deletions

View File

@ -1087,6 +1087,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
_ => bug!("cannot get associated-item of `{:?}`", self.def_key(id)),
};
let container = self.root.tables.assoc_container.get(self, id).unwrap();
let opt_rpitit_info =
self.root.tables.opt_rpitit_info.get(self, id).map(|d| d.decode(self));
ty::AssocItem {
name,
@ -1095,8 +1097,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
trait_item_def_id: self.get_trait_item_def_id(id),
container,
fn_has_self_parameter: has_self,
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): We need to encode this
opt_rpitit_info: None,
opt_rpitit_info,
}
}

View File

@ -1350,6 +1350,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
if trait_item.kind == ty::AssocKind::Fn {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
}
if let Some(rpitit_info) = trait_item.opt_rpitit_info {
let rpitit_info = self.lazy(rpitit_info);
self.tables.opt_rpitit_info.set_some(def_id.index, rpitit_info);
}
}
fn encode_info_for_impl_item(&mut self, def_id: DefId) {
@ -1383,6 +1387,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
self.tables.is_intrinsic.set(def_id.index, tcx.is_intrinsic(def_id));
}
if let Some(rpitit_info) = impl_item.opt_rpitit_info {
let rpitit_info = self.lazy(rpitit_info);
self.tables.opt_rpitit_info.set_some(def_id.index, rpitit_info);
}
}
fn encode_mir(&mut self) {

View File

@ -355,6 +355,7 @@ define_tables! {
inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
associated_items_for_impl_trait_in_trait: Table<DefIndex, LazyArray<DefId>>,
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
- optional:
attributes: Table<DefIndex, LazyArray<ast::Attribute>>,

View File

@ -63,6 +63,7 @@ trivially_parameterized_over_tcx! {
ty::DeducedParamAttrs,
ty::Generics,
ty::ImplPolarity,
ty::ImplTraitInTraitData,
ty::ReprOptions,
ty::TraitDef,
ty::UnusedGenericParams,

View File

@ -119,12 +119,9 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
// When computing the param_env of an RPITIT, copy param_env of the containing function. The
// synthesized associated type doesn't have extra predicates to assume.
let def_id =
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
fn_def_id
} else {
def_id
};
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
return tcx.param_env(fn_def_id);
}
// Compute the bounds on Self and the type parameters.
let ty::InstantiatedPredicates { mut predicates, .. } =