Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis
Move binder for dyn to each list item This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`. This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.` r? `@nikomatsakis`
This commit is contained in:
@@ -87,7 +87,7 @@ pub struct CtxtInterners<'tcx> {
|
||||
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
|
||||
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
|
||||
region: InternedSet<'tcx, RegionKind>,
|
||||
existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
|
||||
poly_existential_predicates: InternedSet<'tcx, List<ty::Binder<ExistentialPredicate<'tcx>>>>,
|
||||
predicate: InternedSet<'tcx, PredicateInner<'tcx>>,
|
||||
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
|
||||
projs: InternedSet<'tcx, List<ProjectionKind>>,
|
||||
@@ -103,7 +103,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||
type_list: Default::default(),
|
||||
substs: Default::default(),
|
||||
region: Default::default(),
|
||||
existential_predicates: Default::default(),
|
||||
poly_existential_predicates: Default::default(),
|
||||
canonical_var_infos: Default::default(),
|
||||
predicate: Default::default(),
|
||||
predicates: Default::default(),
|
||||
@@ -1623,7 +1623,7 @@ nop_lift! {const_; &'a Const<'a> => &'tcx Const<'tcx>}
|
||||
nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
|
||||
|
||||
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
|
||||
nop_list_lift! {existential_predicates; ExistentialPredicate<'a> => ExistentialPredicate<'tcx>}
|
||||
nop_list_lift! {poly_existential_predicates; ty::Binder<ExistentialPredicate<'a>> => ty::Binder<ExistentialPredicate<'tcx>>}
|
||||
nop_list_lift! {predicates; Predicate<'a> => Predicate<'tcx>}
|
||||
nop_list_lift! {canonical_var_infos; CanonicalVarInfo<'a> => CanonicalVarInfo<'tcx>}
|
||||
nop_list_lift! {projs; ProjectionKind => ProjectionKind}
|
||||
@@ -2064,7 +2064,8 @@ slice_interners!(
|
||||
type_list: _intern_type_list(Ty<'tcx>),
|
||||
substs: _intern_substs(GenericArg<'tcx>),
|
||||
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
|
||||
existential_predicates: _intern_existential_predicates(ExistentialPredicate<'tcx>),
|
||||
poly_existential_predicates:
|
||||
_intern_poly_existential_predicates(ty::Binder<ExistentialPredicate<'tcx>>),
|
||||
predicates: _intern_predicates(Predicate<'tcx>),
|
||||
projs: _intern_projs(ProjectionKind),
|
||||
place_elems: _intern_place_elems(PlaceElem<'tcx>),
|
||||
@@ -2295,7 +2296,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
#[inline]
|
||||
pub fn mk_dynamic(
|
||||
self,
|
||||
obj: ty::Binder<&'tcx List<ExistentialPredicate<'tcx>>>,
|
||||
obj: &'tcx List<ty::Binder<ExistentialPredicate<'tcx>>>,
|
||||
reg: ty::Region<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
self.mk_ty(Dynamic(obj, reg))
|
||||
@@ -2425,13 +2426,17 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
Place { local: place.local, projection: self.intern_place_elems(&projection) }
|
||||
}
|
||||
|
||||
pub fn intern_existential_predicates(
|
||||
pub fn intern_poly_existential_predicates(
|
||||
self,
|
||||
eps: &[ExistentialPredicate<'tcx>],
|
||||
) -> &'tcx List<ExistentialPredicate<'tcx>> {
|
||||
eps: &[ty::Binder<ExistentialPredicate<'tcx>>],
|
||||
) -> &'tcx List<ty::Binder<ExistentialPredicate<'tcx>>> {
|
||||
assert!(!eps.is_empty());
|
||||
assert!(eps.array_windows().all(|[a, b]| a.stable_cmp(self, b) != Ordering::Greater));
|
||||
self._intern_existential_predicates(eps)
|
||||
assert!(
|
||||
eps.array_windows()
|
||||
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder())
|
||||
!= Ordering::Greater)
|
||||
);
|
||||
self._intern_poly_existential_predicates(eps)
|
||||
}
|
||||
|
||||
pub fn intern_predicates(self, preds: &[Predicate<'tcx>]) -> &'tcx List<Predicate<'tcx>> {
|
||||
@@ -2488,13 +2493,16 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn mk_existential_predicates<
|
||||
I: InternAs<[ExistentialPredicate<'tcx>], &'tcx List<ExistentialPredicate<'tcx>>>,
|
||||
pub fn mk_poly_existential_predicates<
|
||||
I: InternAs<
|
||||
[ty::Binder<ExistentialPredicate<'tcx>>],
|
||||
&'tcx List<ty::Binder<ExistentialPredicate<'tcx>>>,
|
||||
>,
|
||||
>(
|
||||
self,
|
||||
iter: I,
|
||||
) -> I::Output {
|
||||
iter.intern_with(|xs| self.intern_existential_predicates(xs))
|
||||
iter.intern_with(|xs| self.intern_poly_existential_predicates(xs))
|
||||
}
|
||||
|
||||
pub fn mk_predicates<I: InternAs<[Predicate<'tcx>], &'tcx List<Predicate<'tcx>>>>(
|
||||
|
||||
Reference in New Issue
Block a user