Rename ToPredicate for Upcast
This commit is contained in:
parent
97bf25c8cf
commit
11ec3eca74
44 changed files with 214 additions and 220 deletions
|
@ -73,7 +73,7 @@ use rustc_middle::bug;
|
|||
use rustc_middle::dep_graph::DepContext;
|
||||
use rustc_middle::ty::print::{with_forced_trimmed_paths, PrintError, PrintTraitRefExt as _};
|
||||
use rustc_middle::ty::relate::{self, RelateResult, TypeRelation};
|
||||
use rustc_middle::ty::ToPredicate;
|
||||
use rustc_middle::ty::Upcast;
|
||||
use rustc_middle::ty::{
|
||||
self, error::TypeError, IsSuggestable, List, Region, Ty, TyCtxt, TypeFoldable,
|
||||
TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
|
||||
|
@ -516,7 +516,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
RegionResolutionError::CannotNormalize(clause, origin) => {
|
||||
let clause: ty::Clause<'tcx> =
|
||||
clause.map_bound(ty::ClauseKind::TypeOutlives).to_predicate(self.tcx);
|
||||
clause.map_bound(ty::ClauseKind::TypeOutlives).upcast(self.tcx);
|
||||
self.tcx
|
||||
.dcx()
|
||||
.struct_span_err(origin.span(), format!("cannot normalize `{clause}`"))
|
||||
|
|
|
@ -29,7 +29,7 @@ use rustc_middle::infer::canonical::OriginalQueryValues;
|
|||
use rustc_middle::infer::unify_key::EffectVarValue;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::relate::{RelateResult, TypeRelation};
|
||||
use rustc_middle::ty::{self, InferConst, ToPredicate, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeVisitableExt, Upcast};
|
||||
use rustc_middle::ty::{IntType, UintType};
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -337,7 +337,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
|||
self.obligations.extend(obligations);
|
||||
}
|
||||
|
||||
pub fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>) {
|
||||
pub fn register_predicates(&mut self, obligations: impl IntoIterator<Item: Upcast<'tcx>>) {
|
||||
self.obligations.extend(obligations.into_iter().map(|to_pred| {
|
||||
Obligation::new(self.infcx.tcx, self.trace.cause.clone(), self.param_env, to_pred)
|
||||
}))
|
||||
|
@ -360,7 +360,7 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
|
|||
/// Register predicates that must hold in order for this relation to hold. Uses
|
||||
/// a default obligation cause, [`ObligationEmittingRelation::register_obligations`] should
|
||||
/// be used if control over the obligation causes is required.
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>);
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: Upcast<'tcx>>);
|
||||
|
||||
/// Register `AliasRelate` obligation(s) that both types must be related to each other.
|
||||
fn register_type_relate_obligation(&mut self, a: Ty<'tcx>, b: Ty<'tcx>);
|
||||
|
|
|
@ -140,7 +140,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
|
|||
self.fields.param_env
|
||||
}
|
||||
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
||||
self.fields.register_predicates(obligations);
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
|
|||
self.fields.param_env
|
||||
}
|
||||
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
||||
self.fields.register_predicates(obligations);
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
|
|||
self.structurally_relate_aliases
|
||||
}
|
||||
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
|
||||
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::Upcast<'tcx>>) {
|
||||
self.fields.register_predicates(obligations);
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue