Skip to content

Commit 6bb470e

Browse files
committed
introduce ty::WhereClause to align chalk and rustc dyn repr
1 parent f820d9d commit 6bb470e

File tree

30 files changed

+95
-120
lines changed

30 files changed

+95
-120
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
7474

7575
fn print_dyn_existential(
7676
mut self,
77-
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
77+
predicates: &'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
7878
) -> Result<Self::DynExistential, Self::Error> {
7979
let mut first = true;
8080
for p in predicates {

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,10 @@ impl Checker<'mir, 'tcx> {
376376
ty::Dynamic(preds, _) => {
377377
for pred in preds.iter() {
378378
match pred.skip_binder() {
379-
ty::ExistentialPredicate::AutoTrait(_)
380-
| ty::ExistentialPredicate::Projection(_) => {
379+
ty::WhereClause::AutoTrait(_) | ty::WhereClause::Projection(_) => {
381380
self.check_op(ops::ty::DynTrait(kind))
382381
}
383-
ty::ExistentialPredicate::Trait(trait_ref) => {
382+
ty::WhereClause::Trait(trait_ref) => {
384383
if Some(trait_ref.def_id) != self.tcx.lang_items().sized_trait() {
385384
self.check_op(ops::ty::DynTrait(kind))
386385
}

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
482482

483483
fn print_dyn_existential(
484484
self,
485-
_predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
485+
_predicates: &'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
486486
) -> Result<Self::DynExistential, Self::Error> {
487487
Err(NonTrivialPath)
488488
}

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ impl<'tcx> LateContext<'tcx> {
994994

995995
fn print_dyn_existential(
996996
self,
997-
_predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
997+
_predicates: &'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
998998
) -> Result<Self::DynExistential, Self::Error> {
999999
Ok(())
10001000
}

compiler/rustc_lint/src/unused.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
222222
ty::Dynamic(binder, _) => {
223223
let mut has_emitted = false;
224224
for predicate in binder.iter() {
225-
if let ty::ExistentialPredicate::Trait(ref trait_ref) =
226-
predicate.skip_binder()
227-
{
225+
if let ty::WhereClause::Trait(ref trait_ref) = predicate.skip_binder() {
228226
let def_id = trait_ref.def_id;
229227
let descr_post =
230228
&format!(" trait object{}{}", plural_suffix, descr_post,);

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
322322
}
323323
}
324324

325-
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D>
326-
for ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>
327-
{
325+
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<ty::ExistentialPredicate<'tcx>> {
328326
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
329327
let len = decoder.read_usize()?;
330328
decoder.tcx().mk_poly_existential_predicates((0..len).map(|_| Decodable::decode(decoder)))
@@ -393,7 +391,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<ty::BoundVaria
393391
impl_decodable_via_ref! {
394392
&'tcx ty::TypeckResults<'tcx>,
395393
&'tcx ty::List<Ty<'tcx>>,
396-
&'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
394+
&'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
397395
&'tcx Allocation,
398396
&'tcx mir::Body<'tcx>,
399397
&'tcx mir::UnsafetyCheckResult,
@@ -519,7 +517,7 @@ macro_rules! impl_binder_encode_decode {
519517
impl_binder_encode_decode! {
520518
&'tcx ty::List<Ty<'tcx>>,
521519
ty::FnSig<'tcx>,
522-
ty::ExistentialPredicate<'tcx>,
520+
ty::WhereClause<'tcx>,
523521
ty::TraitRef<'tcx>,
524522
Vec<ty::GeneratorInteriorTypeCause<'tcx>>,
525523
}

compiler/rustc_middle/src/ty/context.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ pub struct CtxtInterners<'tcx> {
103103
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
104104
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
105105
region: InternedSet<'tcx, RegionKind>,
106-
poly_existential_predicates:
107-
InternedSet<'tcx, List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>>,
106+
poly_existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
108107
predicate: InternedSet<'tcx, PredicateInner<'tcx>>,
109108
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
110109
projs: InternedSet<'tcx, List<ProjectionKind>>,
@@ -1672,7 +1671,7 @@ nop_lift! {const_allocation; &'a Allocation => &'tcx Allocation}
16721671
nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
16731672

16741673
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
1675-
nop_list_lift! {poly_existential_predicates; ty::Binder<'a, ExistentialPredicate<'a>> => ty::Binder<'tcx, ExistentialPredicate<'tcx>>}
1674+
nop_list_lift! {poly_existential_predicates; ExistentialPredicate<'a> => ExistentialPredicate<'tcx>}
16761675
nop_list_lift! {predicates; Predicate<'a> => Predicate<'tcx>}
16771676
nop_list_lift! {canonical_var_infos; CanonicalVarInfo<'a> => CanonicalVarInfo<'tcx>}
16781677
nop_list_lift! {projs; ProjectionKind => ProjectionKind}
@@ -2109,7 +2108,7 @@ slice_interners!(
21092108
substs: _intern_substs(GenericArg<'tcx>),
21102109
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
21112110
poly_existential_predicates:
2112-
_intern_poly_existential_predicates(ty::Binder<'tcx, ExistentialPredicate<'tcx>>),
2111+
_intern_poly_existential_predicates(ty::ExistentialPredicate<'tcx>),
21132112
predicates: _intern_predicates(Predicate<'tcx>),
21142113
projs: _intern_projs(ProjectionKind),
21152114
place_elems: _intern_place_elems(PlaceElem<'tcx>),
@@ -2372,7 +2371,7 @@ impl<'tcx> TyCtxt<'tcx> {
23722371
#[inline]
23732372
pub fn mk_dynamic(
23742373
self,
2375-
obj: &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>,
2374+
obj: &'tcx List<ExistentialPredicate<'tcx>>,
23762375
reg: ty::Region<'tcx>,
23772376
) -> Ty<'tcx> {
23782377
self.mk_ty(Dynamic(obj, reg))
@@ -2504,8 +2503,8 @@ impl<'tcx> TyCtxt<'tcx> {
25042503

25052504
pub fn intern_poly_existential_predicates(
25062505
self,
2507-
eps: &[ty::Binder<'tcx, ExistentialPredicate<'tcx>>],
2508-
) -> &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
2506+
eps: &[ty::ExistentialPredicate<'tcx>],
2507+
) -> &'tcx List<ExistentialPredicate<'tcx>> {
25092508
assert!(!eps.is_empty());
25102509
assert!(
25112510
eps.array_windows()
@@ -2577,10 +2576,7 @@ impl<'tcx> TyCtxt<'tcx> {
25772576
}
25782577

25792578
pub fn mk_poly_existential_predicates<
2580-
I: InternAs<
2581-
[ty::Binder<'tcx, ExistentialPredicate<'tcx>>],
2582-
&'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>,
2583-
>,
2579+
I: InternAs<[ExistentialPredicate<'tcx>], &'tcx List<ExistentialPredicate<'tcx>>>,
25842580
>(
25852581
self,
25862582
iter: I,

compiler/rustc_middle/src/ty/error.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ pub enum TypeError<'tcx> {
6262
CyclicTy(Ty<'tcx>),
6363
CyclicConst(&'tcx ty::Const<'tcx>),
6464
ProjectionMismatched(ExpectedFound<DefId>),
65-
ExistentialMismatch(
66-
ExpectedFound<&'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>>,
67-
),
65+
ExistentialMismatch(ExpectedFound<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>),
6866
ObjectUnsafeCoercion(DefId),
6967
ConstMismatch(ExpectedFound<&'tcx ty::Const<'tcx>>),
7068

compiler/rustc_middle/src/ty/flags.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ impl FlagComputation {
174174
&ty::Dynamic(obj, r) => {
175175
for predicate in obj.iter() {
176176
self.bound_computation(predicate, |computation, predicate| match predicate {
177-
ty::ExistentialPredicate::Trait(tr) => computation.add_substs(tr.substs),
178-
ty::ExistentialPredicate::Projection(p) => {
177+
ty::WhereClause::Trait(tr) => computation.add_substs(tr.substs),
178+
ty::WhereClause::Projection(p) => {
179179
computation.add_existential_projection(&p);
180180
}
181-
ty::ExistentialPredicate::AutoTrait(_) => {}
181+
ty::WhereClause::AutoTrait(_) => {}
182182
});
183183
}
184184

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub use self::sty::{
7777
GeneratorSubsts, GeneratorSubstsParts, InlineConstSubsts, InlineConstSubstsParts, ParamConst,
7878
ParamTy, PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig,
7979
PolyTraitRef, ProjectionTy, Region, RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut,
80-
UpvarSubsts, VarianceDiagInfo, VarianceDiagMutKind,
80+
UpvarSubsts, VarianceDiagInfo, VarianceDiagMutKind, WhereClause,
8181
};
8282
pub use self::trait_def::TraitDef;
8383

0 commit comments

Comments
 (0)