Skip to content

Commit 992d154

Browse files
committed
Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorino
Encode `opt_rpitit_info` for associated types Follow-up, only last commit matters r? `@spastorino` This needs a perf run after the parent pr lands
2 parents e84e5ff + 0404e26 commit 992d154

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

Diff for: compiler/rustc_metadata/src/rmeta/decoder.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10871087
_ => bug!("cannot get associated-item of `{:?}`", self.def_key(id)),
10881088
};
10891089
let container = self.root.tables.assoc_container.get(self, id).unwrap();
1090+
let opt_rpitit_info =
1091+
self.root.tables.opt_rpitit_info.get(self, id).map(|d| d.decode(self));
10901092

10911093
ty::AssocItem {
10921094
name,
@@ -1095,8 +1097,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10951097
trait_item_def_id: self.get_trait_item_def_id(id),
10961098
container,
10971099
fn_has_self_parameter: has_self,
1098-
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): We need to encode this
1099-
opt_rpitit_info: None,
1100+
opt_rpitit_info,
11001101
}
11011102
}
11021103

Diff for: compiler/rustc_metadata/src/rmeta/encoder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13501350
if trait_item.kind == ty::AssocKind::Fn {
13511351
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
13521352
}
1353+
if let Some(rpitit_info) = trait_item.opt_rpitit_info {
1354+
let rpitit_info = self.lazy(rpitit_info);
1355+
self.tables.opt_rpitit_info.set_some(def_id.index, rpitit_info);
1356+
}
13531357
}
13541358

13551359
fn encode_info_for_impl_item(&mut self, def_id: DefId) {
@@ -1384,6 +1388,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13841388
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
13851389
self.tables.is_intrinsic.set(def_id.index, tcx.is_intrinsic(def_id));
13861390
}
1391+
if let Some(rpitit_info) = impl_item.opt_rpitit_info {
1392+
let rpitit_info = self.lazy(rpitit_info);
1393+
self.tables.opt_rpitit_info.set_some(def_id.index, rpitit_info);
1394+
}
13871395
}
13881396

13891397
fn encode_mir(&mut self) {

Diff for: compiler/rustc_metadata/src/rmeta/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ define_tables! {
355355
inferred_outlives_of: Table<DefIndex, LazyArray<(ty::Clause<'static>, Span)>>,
356356
inherent_impls: Table<DefIndex, LazyArray<DefIndex>>,
357357
associated_items_for_impl_trait_in_trait: Table<DefIndex, LazyArray<DefId>>,
358+
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
358359

359360
- optional:
360361
attributes: Table<DefIndex, LazyArray<ast::Attribute>>,

Diff for: compiler/rustc_middle/src/ty/parameterized.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ trivially_parameterized_over_tcx! {
6363
ty::DeducedParamAttrs,
6464
ty::Generics,
6565
ty::ImplPolarity,
66+
ty::ImplTraitInTraitData,
6667
ty::ReprOptions,
6768
ty::TraitDef,
6869
ty::UnusedGenericParams,

Diff for: compiler/rustc_ty_utils/src/ty.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,9 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
119119
fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
120120
// When computing the param_env of an RPITIT, copy param_env of the containing function. The
121121
// synthesized associated type doesn't have extra predicates to assume.
122-
let def_id =
123-
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
124-
fn_def_id
125-
} else {
126-
def_id
127-
};
122+
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
123+
return tcx.param_env(fn_def_id);
124+
}
128125

129126
// Compute the bounds on Self and the type parameters.
130127
let ty::InstantiatedPredicates { mut predicates, .. } =

0 commit comments

Comments
 (0)