Remove ToPredicate impls that use Binder::dummy
This commit is contained in:
parent
2c7bc5e33c
commit
be76bdf905
27 changed files with 99 additions and 85 deletions
|
@ -89,10 +89,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
category: ConstraintCategory,
|
category: ConstraintCategory,
|
||||||
) {
|
) {
|
||||||
self.prove_predicates(
|
self.prove_predicates(
|
||||||
Some(ty::PredicateKind::Trait(ty::TraitPredicate {
|
Some(ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
constness: ty::BoundConstness::NotConst,
|
constness: ty::BoundConstness::NotConst,
|
||||||
})),
|
}))),
|
||||||
locations,
|
locations,
|
||||||
category,
|
category,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1078,7 +1078,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.prove_predicate(
|
self.prove_predicate(
|
||||||
ty::PredicateKind::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(inferred_ty.into()))
|
||||||
|
.to_predicate(self.tcx()),
|
||||||
Locations::All(span),
|
Locations::All(span),
|
||||||
ConstraintCategory::TypeAnnotation,
|
ConstraintCategory::TypeAnnotation,
|
||||||
);
|
);
|
||||||
|
@ -1314,7 +1315,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
obligations.obligations.push(traits::Obligation::new(
|
obligations.obligations.push(traits::Obligation::new(
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(revealed_ty.into()))
|
||||||
|
.to_predicate(infcx.tcx),
|
||||||
));
|
));
|
||||||
obligations.add(
|
obligations.add(
|
||||||
infcx
|
infcx
|
||||||
|
@ -1584,7 +1586,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
self.check_call_dest(body, term, &sig, destination, term_location);
|
self.check_call_dest(body, term, &sig, destination, term_location);
|
||||||
|
|
||||||
self.prove_predicates(
|
self.prove_predicates(
|
||||||
sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())),
|
sig.inputs_and_output
|
||||||
|
.iter()
|
||||||
|
.map(|ty| ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))),
|
||||||
term_location.to_locations(),
|
term_location.to_locations(),
|
||||||
ConstraintCategory::Boring,
|
ConstraintCategory::Boring,
|
||||||
);
|
);
|
||||||
|
|
|
@ -669,8 +669,10 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
|
||||||
self.obligations.push(Obligation {
|
self.obligations.push(Obligation {
|
||||||
cause: self.cause.clone(),
|
cause: self.cause.clone(),
|
||||||
param_env: self.param_env,
|
param_env: self.param_env,
|
||||||
predicate: ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(sup, sub))
|
predicate: ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
||||||
.to_predicate(self.infcx.tcx),
|
sup, sub,
|
||||||
|
)))
|
||||||
|
.to_predicate(self.infcx.tcx),
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,8 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||||
self.obligations.push(Obligation::new(
|
self.obligations.push(Obligation::new(
|
||||||
self.trace.cause.clone(),
|
self.trace.cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(b_ty.into()))
|
||||||
|
.to_predicate(self.infcx.tcx),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +464,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||||
self.obligations.push(Obligation::new(
|
self.obligations.push(Obligation::new(
|
||||||
self.trace.cause.clone(),
|
self.trace.cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
predicate.to_predicate(self.tcx()),
|
ty::Binder::dummy(predicate).to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,11 +97,11 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
|
||||||
self.fields.obligations.push(Obligation::new(
|
self.fields.obligations.push(Obligation::new(
|
||||||
self.fields.trace.cause.clone(),
|
self.fields.trace.cause.clone(),
|
||||||
self.fields.param_env,
|
self.fields.param_env,
|
||||||
ty::PredicateKind::Subtype(ty::SubtypePredicate {
|
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
|
||||||
a_is_expected: self.a_is_expected,
|
a_is_expected: self.a_is_expected,
|
||||||
a,
|
a,
|
||||||
b,
|
b,
|
||||||
})
|
}))
|
||||||
.to_predicate(self.tcx()),
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
|
||||||
cause,
|
cause,
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
param_env,
|
param_env,
|
||||||
predicate: trait_ref.without_const().to_predicate(infcx.tcx),
|
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(infcx.tcx),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,7 @@ impl Elaborator<'tcx> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.map(ty::Binder::dummy)
|
||||||
.map(|predicate_kind| predicate_kind.to_predicate(tcx))
|
.map(|predicate_kind| predicate_kind.to_predicate(tcx))
|
||||||
.filter(|&predicate| visited.insert(predicate))
|
.filter(|&predicate| visited.insert(predicate))
|
||||||
.map(|predicate| {
|
.map(|predicate| {
|
||||||
|
|
|
@ -792,23 +792,6 @@ impl ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToPredicate<'tcx> for PredicateKind<'tcx> {
|
|
||||||
#[inline(always)]
|
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
||||||
tcx.mk_predicate(Binder::dummy(self))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
|
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
|
||||||
PredicateKind::Trait(ty::TraitPredicate {
|
|
||||||
trait_ref: self.value,
|
|
||||||
constness: self.constness,
|
|
||||||
})
|
|
||||||
.to_predicate(tcx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
|
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
self.value
|
self.value
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
||||||
let obligation = traits::Obligation::new(
|
let obligation = traits::Obligation::new(
|
||||||
cause.clone(),
|
cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
trait_ref.without_const().to_predicate(tcx),
|
ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
|
||||||
);
|
);
|
||||||
if !self.infcx.predicate_may_hold(&obligation) {
|
if !self.infcx.predicate_may_hold(&obligation) {
|
||||||
debug!("overloaded_deref_ty: cannot match obligation");
|
debug!("overloaded_deref_ty: cannot match obligation");
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
||||||
cause: traits::ObligationCause::dummy(),
|
cause: traits::ObligationCause::dummy(),
|
||||||
param_env,
|
param_env,
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
predicate: trait_ref.without_const().to_predicate(self.tcx),
|
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(self.tcx),
|
||||||
};
|
};
|
||||||
self.evaluate_obligation(&obligation).unwrap_or(traits::EvaluationResult::EvaluatedToErr)
|
self.evaluate_obligation(&obligation).unwrap_or(traits::EvaluationResult::EvaluatedToErr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -724,7 +724,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
let new_obligation = Obligation::new(
|
let new_obligation = Obligation::new(
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
param_env,
|
param_env,
|
||||||
new_trait_ref.without_const().to_predicate(self.tcx),
|
ty::Binder::dummy(new_trait_ref).without_const().to_predicate(self.tcx),
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.predicate_must_hold_modulo_regions(&new_obligation) {
|
if self.predicate_must_hold_modulo_regions(&new_obligation) {
|
||||||
|
|
|
@ -405,7 +405,8 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||||
| ty::PredicateKind::Coerce(_)
|
| ty::PredicateKind::Coerce(_)
|
||||||
| ty::PredicateKind::ConstEvaluatable(..)
|
| ty::PredicateKind::ConstEvaluatable(..)
|
||||||
| ty::PredicateKind::ConstEquate(..) => {
|
| ty::PredicateKind::ConstEquate(..) => {
|
||||||
let pred = infcx.replace_bound_vars_with_placeholders(binder);
|
let pred =
|
||||||
|
ty::Binder::dummy(infcx.replace_bound_vars_with_placeholders(binder));
|
||||||
ProcessResult::Changed(mk_pending(vec![
|
ProcessResult::Changed(mk_pending(vec![
|
||||||
obligation.with(pred.to_predicate(self.selcx.tcx())),
|
obligation.with(pred.to_predicate(self.selcx.tcx())),
|
||||||
]))
|
]))
|
||||||
|
|
|
@ -139,7 +139,8 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
|
||||||
infcx.tcx.def_path_str(def_id)
|
infcx.tcx.def_path_str(def_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
let trait_ref = ty::TraitRef { def_id, substs: infcx.tcx.mk_substs_trait(ty, &[]) };
|
let trait_ref =
|
||||||
|
ty::Binder::dummy(ty::TraitRef { def_id, substs: infcx.tcx.mk_substs_trait(ty, &[]) });
|
||||||
let obligation = Obligation {
|
let obligation = Obligation {
|
||||||
param_env,
|
param_env,
|
||||||
cause: ObligationCause::misc(span, hir::CRATE_HIR_ID),
|
cause: ObligationCause::misc(span, hir::CRATE_HIR_ID),
|
||||||
|
|
|
@ -671,10 +671,10 @@ fn receiver_is_dispatchable<'tcx>(
|
||||||
let param_env = tcx.param_env(method.def_id);
|
let param_env = tcx.param_env(method.def_id);
|
||||||
|
|
||||||
// Self: Unsize<U>
|
// Self: Unsize<U>
|
||||||
let unsize_predicate = ty::TraitRef {
|
let unsize_predicate = ty::Binder::dummy(ty::TraitRef {
|
||||||
def_id: unsize_did,
|
def_id: unsize_did,
|
||||||
substs: tcx.mk_substs_trait(tcx.types.self_param, &[unsized_self_ty.into()]),
|
substs: tcx.mk_substs_trait(tcx.types.self_param, &[unsized_self_ty.into()]),
|
||||||
}
|
})
|
||||||
.without_const()
|
.without_const()
|
||||||
.to_predicate(tcx);
|
.to_predicate(tcx);
|
||||||
|
|
||||||
|
@ -689,7 +689,9 @@ fn receiver_is_dispatchable<'tcx>(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ty::TraitRef { def_id: unsize_did, substs }.without_const().to_predicate(tcx)
|
ty::Binder::dummy(ty::TraitRef { def_id: unsize_did, substs })
|
||||||
|
.without_const()
|
||||||
|
.to_predicate(tcx)
|
||||||
};
|
};
|
||||||
|
|
||||||
let caller_bounds: Vec<Predicate<'tcx>> = param_env
|
let caller_bounds: Vec<Predicate<'tcx>> = param_env
|
||||||
|
@ -703,10 +705,10 @@ fn receiver_is_dispatchable<'tcx>(
|
||||||
|
|
||||||
// Receiver: DispatchFromDyn<Receiver[Self => U]>
|
// Receiver: DispatchFromDyn<Receiver[Self => U]>
|
||||||
let obligation = {
|
let obligation = {
|
||||||
let predicate = ty::TraitRef {
|
let predicate = ty::Binder::dummy(ty::TraitRef {
|
||||||
def_id: dispatch_from_dyn_did,
|
def_id: dispatch_from_dyn_did,
|
||||||
substs: tcx.mk_substs_trait(receiver_ty, &[unsized_receiver_ty.into()]),
|
substs: tcx.mk_substs_trait(receiver_ty, &[unsized_receiver_ty.into()]),
|
||||||
}
|
})
|
||||||
.without_const()
|
.without_const()
|
||||||
.to_predicate(tcx);
|
.to_predicate(tcx);
|
||||||
|
|
||||||
|
|
|
@ -646,7 +646,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
obligations.push(Obligation::new(
|
obligations.push(Obligation::new(
|
||||||
obligation.cause.clone(),
|
obligation.cause.clone(),
|
||||||
obligation.param_env,
|
obligation.param_env,
|
||||||
ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)
|
ty::Binder::dummy(ty::PredicateKind::ClosureKind(closure_def_id, substs, kind))
|
||||||
.to_predicate(self.tcx()),
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -898,10 +898,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// We can only make objects from sized types.
|
// We can only make objects from sized types.
|
||||||
let tr = ty::TraitRef::new(
|
let tr = ty::Binder::dummy(ty::TraitRef::new(
|
||||||
tcx.require_lang_item(LangItem::Sized, None),
|
tcx.require_lang_item(LangItem::Sized, None),
|
||||||
tcx.mk_substs_trait(source, &[]),
|
tcx.mk_substs_trait(source, &[]),
|
||||||
);
|
));
|
||||||
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
|
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
|
||||||
|
|
||||||
// If the type is `Foo + 'a`, ensure that the type
|
// If the type is `Foo + 'a`, ensure that the type
|
||||||
|
|
|
@ -248,7 +248,7 @@ pub fn predicate_for_trait_ref<'tcx>(
|
||||||
cause,
|
cause,
|
||||||
param_env,
|
param_env,
|
||||||
recursion_depth,
|
recursion_depth,
|
||||||
predicate: trait_ref.without_const().to_predicate(tcx),
|
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
new_cause,
|
new_cause,
|
||||||
depth,
|
depth,
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(tcx),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -399,7 +399,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
cause.clone(),
|
cause.clone(),
|
||||||
depth,
|
depth,
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(tcx),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -416,7 +416,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
cause,
|
cause,
|
||||||
self.recursion_depth,
|
self.recursion_depth,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
trait_ref.without_const().to_predicate(self.infcx.tcx),
|
ty::Binder::dummy(trait_ref).without_const().to_predicate(self.infcx.tcx),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,9 +443,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
let obligations = self.nominal_obligations(uv.def.did, substs);
|
let obligations = self.nominal_obligations(uv.def.did, substs);
|
||||||
self.out.extend(obligations);
|
self.out.extend(obligations);
|
||||||
|
|
||||||
let predicate = ty::PredicateKind::ConstEvaluatable(
|
let predicate = ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(
|
||||||
ty::Unevaluated::new(uv.def, substs),
|
ty::Unevaluated::new(uv.def, substs),
|
||||||
)
|
))
|
||||||
.to_predicate(self.tcx());
|
.to_predicate(self.tcx());
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::MiscObligation);
|
||||||
self.out.push(traits::Obligation::with_depth(
|
self.out.push(traits::Obligation::with_depth(
|
||||||
|
@ -469,8 +469,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
cause,
|
cause,
|
||||||
self.recursion_depth,
|
self.recursion_depth,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::WellFormed(resolved_constant.into())
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(
|
||||||
.to_predicate(self.tcx()),
|
resolved_constant.into(),
|
||||||
|
))
|
||||||
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,8 +558,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
cause,
|
cause,
|
||||||
depth,
|
depth,
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(rty, r))
|
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(
|
||||||
.to_predicate(self.tcx()),
|
ty::OutlivesPredicate(rty, r),
|
||||||
|
))
|
||||||
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -646,7 +650,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
cause.clone(),
|
cause.clone(),
|
||||||
depth,
|
depth,
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::ObjectSafe(did).to_predicate(tcx),
|
ty::Binder::dummy(ty::PredicateKind::ObjectSafe(did))
|
||||||
|
.to_predicate(tcx),
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -673,7 +678,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
cause,
|
cause,
|
||||||
self.recursion_depth,
|
self.recursion_depth,
|
||||||
param_env,
|
param_env,
|
||||||
ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into()))
|
||||||
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
// Yes, resolved, proceed with the result.
|
// Yes, resolved, proceed with the result.
|
||||||
|
|
|
@ -156,7 +156,8 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
||||||
self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
|
self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
|
||||||
|
|
||||||
self.prove_predicate(
|
self.prove_predicate(
|
||||||
ty::PredicateKind::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into()))
|
||||||
|
.to_predicate(self.tcx()),
|
||||||
span,
|
span,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +174,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
||||||
// type were ill-formed but did not appear in `ty`,
|
// type were ill-formed but did not appear in `ty`,
|
||||||
// which...could happen with normalization...
|
// which...could happen with normalization...
|
||||||
self.prove_predicate(
|
self.prove_predicate(
|
||||||
ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(ty.into())).to_predicate(self.tcx()),
|
||||||
span,
|
span,
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -524,13 +524,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
for o in obligations {
|
for o in obligations {
|
||||||
match o.predicate.kind().skip_binder() {
|
match o.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(t) => {
|
ty::PredicateKind::Trait(t) => {
|
||||||
let pred = ty::PredicateKind::Trait(ty::TraitPredicate {
|
let pred =
|
||||||
trait_ref: ty::TraitRef {
|
ty::Binder::dummy(ty::PredicateKind::Trait(ty::TraitPredicate {
|
||||||
def_id: t.def_id(),
|
trait_ref: ty::TraitRef {
|
||||||
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]),
|
def_id: t.def_id(),
|
||||||
},
|
substs: self.infcx.tcx.mk_substs_trait(outer_ty, &[]),
|
||||||
constness: t.constness,
|
},
|
||||||
});
|
constness: t.constness,
|
||||||
|
}));
|
||||||
let obl = Obligation::new(
|
let obl = Obligation::new(
|
||||||
o.cause.clone(),
|
o.cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
|
|
|
@ -273,10 +273,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||||
obligations.push(Obligation::new(
|
obligations.push(Obligation::new(
|
||||||
self.cause.clone(),
|
self.cause.clone(),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::Coerce(ty::CoercePredicate {
|
ty::Binder::dummy(ty::PredicateKind::Coerce(ty::CoercePredicate {
|
||||||
a: source_ty,
|
a: source_ty,
|
||||||
b: target_ty,
|
b: target_ty,
|
||||||
})
|
}))
|
||||||
.to_predicate(self.tcx()),
|
.to_predicate(self.tcx()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,7 +568,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.register_predicate(traits::Obligation::new(
|
self.register_predicate(traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::WellFormed(arg).to_predicate(self.tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(self.tcx),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
obligations.push(traits::Obligation::new(
|
obligations.push(traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::WellFormed(method_ty.into()).to_predicate(tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(method_ty.into())).to_predicate(tcx),
|
||||||
));
|
));
|
||||||
|
|
||||||
let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };
|
let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };
|
||||||
|
|
|
@ -1470,7 +1470,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let predicate = trait_ref.without_const().to_predicate(self.tcx);
|
let predicate =
|
||||||
|
ty::Binder::dummy(trait_ref).without_const().to_predicate(self.tcx);
|
||||||
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
|
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
|
||||||
if !self.predicate_may_hold(&obligation) {
|
if !self.predicate_may_hold(&obligation) {
|
||||||
result = ProbeResult::NoMatch;
|
result = ProbeResult::NoMatch;
|
||||||
|
|
|
@ -541,10 +541,10 @@ fn check_type_defn<'tcx, F>(
|
||||||
fcx.register_predicate(traits::Obligation::new(
|
fcx.register_predicate(traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
fcx.param_env,
|
fcx.param_env,
|
||||||
ty::PredicateKind::ConstEvaluatable(ty::Unevaluated::new(
|
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(ty::Unevaluated::new(
|
||||||
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
|
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
|
||||||
discr_substs,
|
discr_substs,
|
||||||
))
|
)))
|
||||||
.to_predicate(tcx),
|
.to_predicate(tcx),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1290,10 +1290,10 @@ fn receiver_is_implemented(
|
||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
receiver_ty: Ty<'tcx>,
|
receiver_ty: Ty<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let trait_ref = ty::TraitRef {
|
let trait_ref = ty::Binder::dummy(ty::TraitRef {
|
||||||
def_id: receiver_trait_def_id,
|
def_id: receiver_trait_def_id,
|
||||||
substs: fcx.tcx.mk_substs_trait(receiver_ty, &[]),
|
substs: fcx.tcx.mk_substs_trait(receiver_ty, &[]),
|
||||||
};
|
});
|
||||||
|
|
||||||
let obligation = traits::Obligation::new(
|
let obligation = traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
|
|
|
@ -607,7 +607,8 @@ fn type_param_predicates(
|
||||||
ItemKind::Trait(_, _, ref generics, ..) => {
|
ItemKind::Trait(_, _, ref generics, ..) => {
|
||||||
// Implied `Self: Trait` and supertrait bounds.
|
// Implied `Self: Trait` and supertrait bounds.
|
||||||
if param_id == item_hir_id {
|
if param_id == item_hir_id {
|
||||||
let identity_trait_ref = ty::TraitRef::identity(tcx, item_def_id);
|
let identity_trait_ref =
|
||||||
|
ty::Binder::dummy(ty::TraitRef::identity(tcx, item_def_id));
|
||||||
extend =
|
extend =
|
||||||
Some((identity_trait_ref.without_const().to_predicate(tcx), item.span));
|
Some((identity_trait_ref.without_const().to_predicate(tcx), item.span));
|
||||||
}
|
}
|
||||||
|
@ -2002,11 +2003,14 @@ fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
|
||||||
// *current* state of an external file.
|
// *current* state of an external file.
|
||||||
span = tcx.sess.source_map().guess_head_span(span);
|
span = tcx.sess.source_map().guess_head_span(span);
|
||||||
}
|
}
|
||||||
result.predicates =
|
result.predicates = tcx.arena.alloc_from_iter(
|
||||||
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
|
result.predicates.iter().copied().chain(std::iter::once((
|
||||||
ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(tcx),
|
ty::Binder::dummy(ty::TraitRef::identity(tcx, def_id))
|
||||||
|
.without_const()
|
||||||
|
.to_predicate(tcx),
|
||||||
span,
|
span,
|
||||||
))));
|
))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
|
debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
|
||||||
result
|
result
|
||||||
|
@ -2238,8 +2242,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||||
}
|
}
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let pred = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
let pred = ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
|
||||||
.to_predicate(icx.tcx);
|
ty::OutlivesPredicate(r1, r2),
|
||||||
|
))
|
||||||
|
.to_predicate(icx.tcx);
|
||||||
|
|
||||||
(pred, span)
|
(pred, span)
|
||||||
}))
|
}))
|
||||||
|
@ -2304,7 +2310,8 @@ fn const_evaluatable_predicates_of<'tcx>(
|
||||||
assert_eq!(uv.promoted, None);
|
assert_eq!(uv.promoted, None);
|
||||||
let span = self.tcx.hir().span(c.hir_id);
|
let span = self.tcx.hir().span(c.hir_id);
|
||||||
self.preds.insert((
|
self.preds.insert((
|
||||||
ty::PredicateKind::ConstEvaluatable(uv.shrink()).to_predicate(self.tcx),
|
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
|
||||||
|
.to_predicate(self.tcx),
|
||||||
span,
|
span,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,8 @@ fn diagnostic_hir_wf_check<'tcx>(
|
||||||
traits::Obligation::new(
|
traits::Obligation::new(
|
||||||
cause,
|
cause,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::PredicateKind::WellFormed(tcx_ty.into()).to_predicate(self.tcx),
|
ty::Binder::dummy(ty::PredicateKind::WellFormed(tcx_ty.into()))
|
||||||
|
.to_predicate(self.tcx),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -104,13 +104,15 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
|
||||||
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
||||||
match kind1.unpack() {
|
match kind1.unpack() {
|
||||||
GenericArgKind::Type(ty1) => Some((
|
GenericArgKind::Type(ty1) => Some((
|
||||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
|
ty::Binder::dummy(ty::PredicateKind::TypeOutlives(
|
||||||
.to_predicate(tcx),
|
ty::OutlivesPredicate(ty1, region2),
|
||||||
|
))
|
||||||
|
.to_predicate(tcx),
|
||||||
span,
|
span,
|
||||||
)),
|
)),
|
||||||
GenericArgKind::Lifetime(region1) => Some((
|
GenericArgKind::Lifetime(region1) => Some((
|
||||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
|
||||||
region1, region2,
|
ty::OutlivesPredicate(region1, region2),
|
||||||
))
|
))
|
||||||
.to_predicate(tcx),
|
.to_predicate(tcx),
|
||||||
span,
|
span,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue