Skip to content

Commit d263dc3

Browse files
committed
remove impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx>
1 parent 465309a commit d263dc3

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2188,16 +2188,18 @@ pub(super) fn check_type_bounds<'tcx>(
21882188
//
21892189
// impl<T> X for T where T: X { type Y = <T as X>::Y; }
21902190
}
2191-
_ => predicates.push(
2192-
ty::Binder::bind_with_vars(
2191+
_ => {
2192+
let pred: ty::Predicate<'_> = ty::Binder::bind_with_vars(
21932193
ty::ProjectionPredicate {
21942194
projection_ty: tcx.mk_alias_ty(trait_ty.def_id, rebased_args),
21952195
term: normalize_impl_ty.into(),
21962196
},
21972197
bound_vars,
21982198
)
2199-
.to_predicate(tcx),
2200-
),
2199+
.to_predicate(tcx);
2200+
2201+
predicates.push(pred.expect_clause())
2202+
}
22012203
};
22022204
ty::ParamEnv::new(tcx.mk_clauses(&predicates), Reveal::UserFacing)
22032205
};

compiler/rustc_middle/src/ty/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1316,13 +1316,6 @@ impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ProjectionPredicate<'tcx> {
13161316
}
13171317
}
13181318

1319-
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
1320-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
1321-
let p: Predicate<'tcx> = self.to_predicate(tcx);
1322-
p.expect_clause()
1323-
}
1324-
}
1325-
13261319
impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
13271320
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13281321
PredicateKind::Clause(ClauseKind::Trait(self)).to_predicate(tcx)

compiler/rustc_middle/src/ty/sty.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,9 @@ impl<'tcx> PolyExistentialPredicate<'tcx> {
725725
self.rebind(tr).with_self_ty(tcx, self_ty).to_predicate(tcx)
726726
}
727727
ExistentialPredicate::Projection(p) => {
728-
self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx)
728+
let pred: ty::Predicate<'tcx> =
729+
self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx);
730+
pred.expect_clause()
729731
}
730732
ExistentialPredicate::AutoTrait(did) => {
731733
let generics = tcx.generics_of(did);

compiler/rustc_trait_selection/src/solve/project_goals.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,22 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
331331
ty::TraitRef::from_lang_item(tcx, LangItem::Sized, DUMMY_SP, [output])
332332
});
333333

334-
let pred = tupled_inputs_and_output
334+
let pred: ty::Predicate<'_> = tupled_inputs_and_output
335335
.map_bound(|(inputs, output)| ty::ProjectionPredicate {
336336
projection_ty: tcx
337337
.mk_alias_ty(goal.predicate.def_id(), [goal.predicate.self_ty(), inputs]),
338338
term: output.into(),
339339
})
340340
.to_predicate(tcx);
341+
341342
// A built-in `Fn` impl only holds if the output is sized.
342343
// (FIXME: technically we only need to check this if the type is a fn ptr...)
343-
Self::consider_implied_clause(ecx, goal, pred, [goal.with(tcx, output_is_sized_pred)])
344+
Self::consider_implied_clause(
345+
ecx,
346+
goal,
347+
pred.expect_clause(),
348+
[goal.with(tcx, output_is_sized_pred)],
349+
)
344350
}
345351

346352
fn consider_builtin_tuple_candidate(

compiler/rustc_trait_selection/src/traits/project.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,10 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
16441644
let env_predicates = data
16451645
.projection_bounds()
16461646
.filter(|bound| bound.item_def_id() == obligation.predicate.def_id)
1647-
.map(|p| p.with_self_ty(tcx, object_ty).to_predicate(tcx));
1647+
.map(|p| {
1648+
let pred: ty::Predicate<'_> = p.with_self_ty(tcx, object_ty).to_predicate(tcx);
1649+
pred.expect_clause()
1650+
});
16481651

16491652
assemble_candidates_from_predicates(
16501653
selcx,

compiler/rustc_ty_utils/src/ty.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,12 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
220220
// strategy, then just reinterpret the associated type like an opaque :^)
221221
let default_ty = self.tcx.type_of(shifted_alias_ty.def_id).instantiate(self.tcx, shifted_alias_ty.args);
222222

223-
self.predicates.push(
224-
ty::Binder::bind_with_vars(
225-
ty::ProjectionPredicate { projection_ty: shifted_alias_ty, term: default_ty.into() },
226-
self.bound_vars,
227-
)
228-
.to_predicate(self.tcx),
229-
);
223+
let pred: ty::Predicate<'_> = ty::Binder::bind_with_vars(
224+
ty::ProjectionPredicate { projection_ty: shifted_alias_ty, term: default_ty.into() },
225+
self.bound_vars,
226+
)
227+
.to_predicate(self.tcx);
228+
self.predicates.push(pred.expect_clause());
230229

231230
// We walk the *un-shifted* alias ty, because we're tracking the de bruijn
232231
// binder depth, and if we were to walk `shifted_alias_ty` instead, we'd

0 commit comments

Comments
 (0)