Rename ToPredicate for Upcast

This commit is contained in:
Michael Goulet
2024-05-15 10:05:25 -04:00
parent 97bf25c8cf
commit 11ec3eca74
44 changed files with 214 additions and 220 deletions

View File

@@ -2,7 +2,7 @@ use crate::infer::InferCtxt;
use crate::traits::Obligation;
use rustc_hir::def_id::DefId;
use rustc_macros::extension;
use rustc_middle::ty::{self, ToPredicate, Ty};
use rustc_middle::ty::{self, Ty, Upcast};
use super::FulfillmentError;
use super::{ObligationCause, PredicateObligation};
@@ -26,7 +26,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
cause,
recursion_depth: 0,
param_env,
predicate: ty::Binder::dummy(trait_ref).to_predicate(infcx.tcx),
predicate: ty::Binder::dummy(trait_ref).upcast(infcx.tcx),
},
);
}

View File

@@ -16,7 +16,7 @@ use rustc_hir as hir;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::solve::Certainty;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, Const, ToPredicate, Ty, TyCtxt};
use rustc_middle::ty::{self, Const, Ty, TyCtxt, Upcast};
use rustc_span::Span;
pub use self::ImplSource::*;
@@ -155,7 +155,7 @@ impl<'tcx, O> Obligation<'tcx, O> {
tcx: TyCtxt<'tcx>,
cause: ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
predicate: impl ToPredicate<'tcx, O>,
predicate: impl Upcast<'tcx, O>,
) -> Obligation<'tcx, O> {
Self::with_depth(tcx, cause, 0, param_env, predicate)
}
@@ -173,9 +173,9 @@ impl<'tcx, O> Obligation<'tcx, O> {
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ty::ParamEnv<'tcx>,
predicate: impl ToPredicate<'tcx, O>,
predicate: impl Upcast<'tcx, O>,
) -> Obligation<'tcx, O> {
let predicate = predicate.to_predicate(tcx);
let predicate = predicate.upcast(tcx);
Obligation { cause, param_env, recursion_depth, predicate }
}
@@ -184,16 +184,12 @@ impl<'tcx, O> Obligation<'tcx, O> {
span: Span,
body_id: LocalDefId,
param_env: ty::ParamEnv<'tcx>,
trait_ref: impl ToPredicate<'tcx, O>,
trait_ref: impl Upcast<'tcx, O>,
) -> Obligation<'tcx, O> {
Obligation::new(tcx, ObligationCause::misc(span, body_id), param_env, trait_ref)
}
pub fn with<P>(
&self,
tcx: TyCtxt<'tcx>,
value: impl ToPredicate<'tcx, P>,
) -> Obligation<'tcx, P> {
pub fn with<P>(&self, tcx: TyCtxt<'tcx>, value: impl Upcast<'tcx, P>) -> Obligation<'tcx, P> {
Obligation::with_depth(tcx, self.cause.clone(), self.recursion_depth, self.param_env, value)
}
}

View File

@@ -3,7 +3,7 @@ use smallvec::smallvec;
use crate::infer::outlives::components::{push_outlives_components, Component};
use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation};
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt};
use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
use rustc_span::symbol::Ident;
use rustc_span::Span;
@@ -358,7 +358,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
}
})
.map(|clause| {
elaboratable.child(bound_clause.rebind(clause).to_predicate(tcx))
elaboratable.child(bound_clause.rebind(clause).upcast(tcx))
}),
);
}
@@ -409,14 +409,14 @@ pub fn supertraits<'tcx>(
tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
) -> FilterToTraits<Elaborator<'tcx, ty::Predicate<'tcx>>> {
elaborate(tcx, [trait_ref.to_predicate(tcx)]).filter_only_self().filter_to_traits()
elaborate(tcx, [trait_ref.upcast(tcx)]).filter_only_self().filter_to_traits()
}
pub fn transitive_bounds<'tcx>(
tcx: TyCtxt<'tcx>,
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
) -> FilterToTraits<Elaborator<'tcx, ty::Predicate<'tcx>>> {
elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.to_predicate(tcx)))
elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.upcast(tcx)))
.filter_only_self()
.filter_to_traits()
}
@@ -431,7 +431,7 @@ pub fn transitive_bounds_that_define_assoc_item<'tcx>(
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
assoc_name: Ident,
) -> FilterToTraits<Elaborator<'tcx, ty::Predicate<'tcx>>> {
elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.to_predicate(tcx)))
elaborate(tcx, trait_refs.map(|trait_ref| trait_ref.upcast(tcx)))
.filter_only_self_that_defines(assoc_name)
.filter_to_traits()
}