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

@@ -14,8 +14,8 @@ use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
use rustc_middle::ty::{
self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, ToPredicate,
TraitPredicate, Ty, TyCtxt,
self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, TraitPredicate, Ty,
TyCtxt, Upcast,
};
use rustc_middle::{bug, span_bug};
use rustc_span::def_id::DefId;
@@ -676,7 +676,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let assoc_ty_args = tcx.mk_args(&args);
let bound =
bound.map_bound(|b| b.kind().skip_binder()).instantiate(tcx, assoc_ty_args);
ty::Binder::bind_with_vars(bound, bound_vars).to_predicate(tcx)
ty::Binder::bind_with_vars(bound, bound_vars).upcast(tcx)
};
let normalized_bound = normalize_with_depth_to(
self,
@@ -1253,13 +1253,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
tcx.require_lang_item(LangItem::Sized, Some(obligation.cause.span)),
[source],
);
nested.push(predicate_to_obligation(tr.to_predicate(tcx)));
nested.push(predicate_to_obligation(tr.upcast(tcx)));
// If the type is `Foo + 'a`, ensure that the type
// being cast to `Foo + 'a` outlives `'a`:
let outlives = ty::OutlivesPredicate(source, r);
nested.push(predicate_to_obligation(
ty::Binder::dummy(ty::ClauseKind::TypeOutlives(outlives)).to_predicate(tcx),
ty::Binder::dummy(ty::ClauseKind::TypeOutlives(outlives)).upcast(tcx),
));
ImplSource::Builtin(BuiltinImplSource::Misc, nested)

View File

@@ -45,7 +45,7 @@ use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::print::PrintTraitRefExt as _;
use rustc_middle::ty::relate::TypeRelation;
use rustc_middle::ty::GenericArgsRef;
use rustc_middle::ty::{self, PolyProjectionPredicate, ToPredicate};
use rustc_middle::ty::{self, PolyProjectionPredicate, Upcast};
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_span::symbol::sym;
use rustc_span::Symbol;
@@ -740,7 +740,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let cycle = stack.iter().take_while(|s| s.depth > stack_arg.1);
let tcx = self.tcx();
let cycle =
cycle.map(|stack| stack.obligation.predicate.to_predicate(tcx));
cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
if self.coinductive_match(cycle) {
stack.update_reached_depth(stack_arg.1);
return Ok(EvaluatedToOk);
@@ -1174,7 +1174,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// if the regions match exactly.
let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
let tcx = self.tcx();
let cycle = cycle.map(|stack| stack.obligation.predicate.to_predicate(tcx));
let cycle = cycle.map(|stack| stack.obligation.predicate.upcast(tcx));
if self.coinductive_match(cycle) {
debug!("evaluate_stack --> recursive, coinductive");
Some(EvaluatedToOk)
@@ -1379,7 +1379,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
error_obligation: &Obligation<'tcx, T>,
) -> Result<(), OverflowError>
where
T: ToPredicate<'tcx> + Clone,
T: Upcast<'tcx> + Clone,
{
if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
match self.query_mode {
@@ -1408,7 +1408,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
error_obligation: &Obligation<'tcx, V>,
) -> Result<(), OverflowError>
where
V: ToPredicate<'tcx> + Clone,
V: Upcast<'tcx> + Clone,
{
self.check_recursion_depth(obligation.recursion_depth, error_obligation)
}