summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_trait_selection/src/traits/relationships.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /compiler/rustc_trait_selection/src/traits/relationships.rs
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/relationships.rs')
-rw-r--r--compiler/rustc_trait_selection/src/traits/relationships.rs28
1 files changed, 9 insertions, 19 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/relationships.rs b/compiler/rustc_trait_selection/src/traits/relationships.rs
index 8cf500a46..bfa318787 100644
--- a/compiler/rustc_trait_selection/src/traits/relationships.rs
+++ b/compiler/rustc_trait_selection/src/traits/relationships.rs
@@ -1,8 +1,8 @@
use crate::infer::InferCtxt;
use crate::traits::query::evaluate_obligation::InferCtxtExt;
-use crate::traits::{ObligationCause, PredicateObligation};
+use crate::traits::PredicateObligation;
use rustc_infer::traits::TraitEngine;
-use rustc_middle::ty::{self, ToPredicate};
+use rustc_middle::ty;
pub(crate) fn update<'tcx, T>(
engine: &mut T,
@@ -12,34 +12,22 @@ pub(crate) fn update<'tcx, T>(
T: TraitEngine<'tcx>,
{
// (*) binder skipped
- if let ty::PredicateKind::Trait(tpred) = obligation.predicate.kind().skip_binder()
+ if let ty::PredicateKind::Clause(ty::Clause::Trait(tpred)) = obligation.predicate.kind().skip_binder()
&& let Some(ty) = infcx.shallow_resolve(tpred.self_ty()).ty_vid().map(|t| infcx.root_var(t))
&& infcx.tcx.lang_items().sized_trait().map_or(false, |st| st != tpred.trait_ref.def_id)
{
let new_self_ty = infcx.tcx.types.unit;
- let trait_ref = ty::TraitRef {
- substs: infcx.tcx.mk_substs_trait(new_self_ty, &tpred.trait_ref.substs[1..]),
- ..tpred.trait_ref
- };
-
// Then construct a new obligation with Self = () added
// to the ParamEnv, and see if it holds.
- let o = rustc_infer::traits::Obligation::new(
- ObligationCause::dummy(),
- obligation.param_env,
+ let o = obligation.with(infcx.tcx,
obligation
.predicate
.kind()
.rebind(
// (*) binder moved here
- ty::PredicateKind::Trait(ty::TraitPredicate {
- trait_ref,
- constness: tpred.constness,
- polarity: tpred.polarity,
- })
- )
- .to_predicate(infcx.tcx),
+ ty::PredicateKind::Clause(ty::Clause::Trait(tpred.with_self_type(infcx.tcx, new_self_ty)))
+ ),
);
// Don't report overflow errors. Otherwise equivalent to may_hold.
if let Ok(result) = infcx.probe(|_| infcx.evaluate_obligation(&o)) && result.may_apply() {
@@ -47,7 +35,9 @@ pub(crate) fn update<'tcx, T>(
}
}
- if let ty::PredicateKind::Projection(predicate) = obligation.predicate.kind().skip_binder() {
+ if let ty::PredicateKind::Clause(ty::Clause::Projection(predicate)) =
+ obligation.predicate.kind().skip_binder()
+ {
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
// we need to make it into one.
if let Some(vid) = predicate.term.ty().and_then(|ty| ty.ty_vid()) {