1
Fork 0

Migrate item_bounds to ty::Clause

This commit is contained in:
Michael Goulet 2023-06-19 20:46:46 +00:00
parent 2efe091705
commit 46a650f4e0
37 changed files with 232 additions and 152 deletions

View file

@ -408,9 +408,9 @@ impl<'tcx> InferCtxt<'tcx> {
predicate
.kind()
.map_bound(|kind| match kind {
ty::PredicateKind::Clause(ty::ClauseKind::Projection(
projection_predicate,
)) if projection_predicate.projection_ty.def_id == item_def_id => {
ty::ClauseKind::Projection(projection_predicate)
if projection_predicate.projection_ty.def_id == item_def_id =>
{
projection_predicate.term.ty()
}
_ => None,

View file

@ -649,9 +649,7 @@ impl<'tcx> InferCtxt<'tcx> {
ct_op: |ct| ct,
});
if let ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) =
predicate.kind().skip_binder()
{
if let ty::ClauseKind::Projection(projection) = predicate.kind().skip_binder() {
if projection.term.references_error() {
// No point on adding any obligations since there's a type error involved.
obligations.clear();

View file

@ -296,7 +296,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
trace!("{:#?}", bounds.skip_binder());
bounds
.subst_iter(tcx, alias_ty.substs)
.filter_map(|p| p.to_opt_type_outlives())
.filter_map(|p| p.as_type_outlives_clause())
.filter_map(|p| p.no_bound_vars())
.map(|OutlivesPredicate(_, r)| r)
}

View file

@ -167,6 +167,26 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Predicate<'tcx>, Span) {
}
}
impl<'tcx> Elaboratable<'tcx> for (ty::Clause<'tcx>, Span) {
fn predicate(&self) -> ty::Predicate<'tcx> {
self.0.as_predicate()
}
fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
(predicate.as_clause().unwrap(), self.1)
}
fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
_span: Span,
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
_index: usize,
) -> Self {
(predicate.as_clause().unwrap(), self.1)
}
}
impl<'tcx> Elaboratable<'tcx> for ty::Clause<'tcx> {
fn predicate(&self) -> ty::Predicate<'tcx> {
self.as_predicate()