Review changes
This commit is contained in:
parent
66c179946b
commit
3dea68de1d
@ -530,10 +530,10 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||
|
||||
let atom = match k1.unpack() {
|
||||
GenericArgKind::Lifetime(r1) => {
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
||||
}
|
||||
GenericArgKind::Type(t1) => {
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(t1, r2))
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t1, r2))
|
||||
}
|
||||
GenericArgKind::Const(..) => {
|
||||
// Consts cannot outlive one another, so we don't expect to
|
||||
@ -663,7 +663,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
|
||||
self.obligations.push(Obligation {
|
||||
cause: self.cause.clone(),
|
||||
param_env: self.param_env,
|
||||
predicate: ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(sup, sub))
|
||||
predicate: ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(sup, sub))
|
||||
.to_predicate(self.infcx.tcx),
|
||||
recursion_depth: 0,
|
||||
});
|
||||
|
@ -358,7 +358,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||
self.obligations.push(Obligation::new(
|
||||
self.trace.cause.clone(),
|
||||
self.param_env,
|
||||
ty::PredicateAtom::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
|
||||
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
|
||||
));
|
||||
}
|
||||
|
||||
@ -451,9 +451,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||
b: &'tcx ty::Const<'tcx>,
|
||||
) {
|
||||
let predicate = if a_is_expected {
|
||||
ty::PredicateAtom::ConstEquate(a, b)
|
||||
ty::PredicateKind::ConstEquate(a, b)
|
||||
} else {
|
||||
ty::PredicateAtom::ConstEquate(b, a)
|
||||
ty::PredicateKind::ConstEquate(b, a)
|
||||
};
|
||||
self.obligations.push(Obligation::new(
|
||||
self.trace.cause.clone(),
|
||||
|
@ -1706,8 +1706,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
|
||||
for (predicate, _) in bounds {
|
||||
let predicate = predicate.subst(self.tcx, substs);
|
||||
if let ty::PredicateAtom::Projection(projection_predicate) =
|
||||
predicate.skip_binders()
|
||||
if let ty::PredicateKind::Projection(projection_predicate) =
|
||||
predicate.kind().skip_binder()
|
||||
{
|
||||
if projection_predicate.projection_ty.item_def_id == item_def_id {
|
||||
// We don't account for multiple `Future::Output = Ty` contraints.
|
||||
|
@ -15,20 +15,21 @@ pub fn explicit_outlives_bounds<'tcx>(
|
||||
param_env
|
||||
.caller_bounds()
|
||||
.into_iter()
|
||||
.map(ty::Predicate::skip_binders)
|
||||
.map(ty::Predicate::kind)
|
||||
.map(ty::Binder::skip_binder)
|
||||
.filter(|atom| !atom.has_escaping_bound_vars())
|
||||
.filter_map(move |atom| match atom {
|
||||
ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::TypeOutlives(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::TypeOutlives(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
Some(OutlivesBound::RegionSubRegion(r_b, r_a))
|
||||
}
|
||||
})
|
||||
|
@ -100,7 +100,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
|
||||
self.fields.obligations.push(Obligation::new(
|
||||
self.fields.trace.cause.clone(),
|
||||
self.fields.param_env,
|
||||
ty::PredicateAtom::Subtype(ty::SubtypePredicate {
|
||||
ty::PredicateKind::Subtype(ty::SubtypePredicate {
|
||||
a_is_expected: self.a_is_expected,
|
||||
a,
|
||||
b,
|
||||
|
@ -9,7 +9,7 @@ pub fn anonymize_predicate<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
pred: ty::Predicate<'tcx>,
|
||||
) -> ty::Predicate<'tcx> {
|
||||
let new = tcx.anonymize_late_bound_regions(pred.bound_atom());
|
||||
let new = tcx.anonymize_late_bound_regions(pred.kind());
|
||||
tcx.reuse_or_mk_predicate(pred, new)
|
||||
}
|
||||
|
||||
@ -121,9 +121,9 @@ impl Elaborator<'tcx> {
|
||||
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
|
||||
let tcx = self.visited.tcx;
|
||||
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(data, _) => {
|
||||
ty::PredicateKind::Trait(data, _) => {
|
||||
// Get predicates declared on the trait.
|
||||
let predicates = tcx.super_predicates_of(data.def_id());
|
||||
|
||||
@ -145,36 +145,36 @@ impl Elaborator<'tcx> {
|
||||
|
||||
self.stack.extend(obligations);
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(..) => {
|
||||
ty::PredicateKind::WellFormed(..) => {
|
||||
// Currently, we do not elaborate WF predicates,
|
||||
// although we easily could.
|
||||
}
|
||||
ty::PredicateAtom::ObjectSafe(..) => {
|
||||
ty::PredicateKind::ObjectSafe(..) => {
|
||||
// Currently, we do not elaborate object-safe
|
||||
// predicates.
|
||||
}
|
||||
ty::PredicateAtom::Subtype(..) => {
|
||||
ty::PredicateKind::Subtype(..) => {
|
||||
// Currently, we do not "elaborate" predicates like `X <: Y`,
|
||||
// though conceivably we might.
|
||||
}
|
||||
ty::PredicateAtom::Projection(..) => {
|
||||
ty::PredicateKind::Projection(..) => {
|
||||
// Nothing to elaborate in a projection predicate.
|
||||
}
|
||||
ty::PredicateAtom::ClosureKind(..) => {
|
||||
ty::PredicateKind::ClosureKind(..) => {
|
||||
// Nothing to elaborate when waiting for a closure's kind to be inferred.
|
||||
}
|
||||
ty::PredicateAtom::ConstEvaluatable(..) => {
|
||||
ty::PredicateKind::ConstEvaluatable(..) => {
|
||||
// Currently, we do not elaborate const-evaluatable
|
||||
// predicates.
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(..) => {
|
||||
ty::PredicateKind::ConstEquate(..) => {
|
||||
// Currently, we do not elaborate const-equate
|
||||
// predicates.
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(..) => {
|
||||
ty::PredicateKind::RegionOutlives(..) => {
|
||||
// Nothing to elaborate from `'a: 'b`.
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_max, r_min)) => {
|
||||
// We know that `T: 'a` for some type `T`. We can
|
||||
// often elaborate this. For example, if we know that
|
||||
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
|
||||
@ -204,7 +204,7 @@ impl Elaborator<'tcx> {
|
||||
if r.is_late_bound() {
|
||||
None
|
||||
} else {
|
||||
Some(ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(
|
||||
Some(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
||||
r, r_min,
|
||||
)))
|
||||
}
|
||||
@ -212,7 +212,7 @@ impl Elaborator<'tcx> {
|
||||
|
||||
Component::Param(p) => {
|
||||
let ty = tcx.mk_ty_param(p.index, p.name);
|
||||
Some(ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(
|
||||
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
||||
ty, r_min,
|
||||
)))
|
||||
}
|
||||
@ -237,7 +237,7 @@ impl Elaborator<'tcx> {
|
||||
}),
|
||||
);
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
// Nothing to elaborate
|
||||
}
|
||||
}
|
||||
|
@ -1550,13 +1550,13 @@ declare_lint_pass!(
|
||||
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::PredicateAtom::*;
|
||||
use rustc_middle::ty::PredicateKind::*;
|
||||
|
||||
if cx.tcx.features().trivial_bounds {
|
||||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
let predicates = cx.tcx.predicates_of(def_id);
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
let predicate_kind_name = match predicate.skip_binders() {
|
||||
let predicate_kind_name = match predicate.kind().skip_binder() {
|
||||
Trait(..) => "Trait",
|
||||
TypeOutlives(..) |
|
||||
RegionOutlives(..) => "Lifetime",
|
||||
@ -1936,8 +1936,8 @@ impl ExplicitOutlivesRequirements {
|
||||
) -> Vec<ty::Region<'tcx>> {
|
||||
inferred_outlives
|
||||
.iter()
|
||||
.filter_map(|(pred, _)| match pred.skip_binders() {
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
|
||||
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
|
||||
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
|
||||
_ => None,
|
||||
},
|
||||
@ -1952,8 +1952,8 @@ impl ExplicitOutlivesRequirements {
|
||||
) -> Vec<ty::Region<'tcx>> {
|
||||
inferred_outlives
|
||||
.iter()
|
||||
.filter_map(|(pred, _)| match pred.skip_binders() {
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
|
||||
.filter_map(|(pred, _)| match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
|
||||
a.is_param(index).then_some(b)
|
||||
}
|
||||
_ => None,
|
||||
|
@ -45,12 +45,12 @@ declare_lint_pass!(
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
use rustc_middle::ty::PredicateAtom::*;
|
||||
use rustc_middle::ty::PredicateKind::*;
|
||||
|
||||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
let predicates = cx.tcx.explicit_predicates_of(def_id);
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
let trait_predicate = match predicate.skip_binders() {
|
||||
let trait_predicate = match predicate.kind().skip_binder() {
|
||||
Trait(trait_predicate, _constness) => trait_predicate,
|
||||
_ => continue,
|
||||
};
|
||||
|
@ -202,8 +202,8 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
||||
let mut has_emitted = false;
|
||||
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
|
||||
// We only look at the `DefId`, so it is safe to skip the binder here.
|
||||
if let ty::PredicateAtom::Trait(ref poly_trait_predicate, _) =
|
||||
predicate.skip_binders()
|
||||
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) =
|
||||
predicate.kind().skip_binder()
|
||||
{
|
||||
let def_id = poly_trait_predicate.trait_ref.def_id;
|
||||
let descr_pre =
|
||||
|
@ -44,9 +44,9 @@ impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::Predicate<'tcx> {
|
||||
type Variant = ty::Binder<ty::PredicateAtom<'tcx>>;
|
||||
type Variant = ty::Binder<ty::PredicateKind<'tcx>>;
|
||||
fn variant(&self) -> &Self::Variant {
|
||||
self.bound_atom_ref()
|
||||
self.kind_ref()
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,9 +226,9 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Predicate<'tcx> {
|
||||
assert!(pos >= SHORTHAND_OFFSET);
|
||||
let shorthand = pos - SHORTHAND_OFFSET;
|
||||
|
||||
decoder.with_position(shorthand, ty::Binder::<ty::PredicateAtom<'tcx>>::decode)
|
||||
decoder.with_position(shorthand, ty::Binder::<ty::PredicateKind<'tcx>>::decode)
|
||||
} else {
|
||||
ty::Binder::<ty::PredicateAtom<'tcx>>::decode(decoder)
|
||||
ty::Binder::<ty::PredicateKind<'tcx>>::decode(decoder)
|
||||
}?;
|
||||
let predicate = decoder.tcx().mk_predicate(predicate_kind);
|
||||
Ok(predicate)
|
||||
|
@ -19,7 +19,7 @@ use crate::ty::TyKind::*;
|
||||
use crate::ty::{
|
||||
self, AdtDef, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid,
|
||||
DefIdTree, ExistentialPredicate, FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy,
|
||||
IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateAtom, PredicateInner,
|
||||
IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, PredicateInner, PredicateKind,
|
||||
ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar,
|
||||
TyVid, TypeAndMut, Visibility,
|
||||
};
|
||||
@ -133,7 +133,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn intern_predicate(&self, binder: Binder<PredicateAtom<'tcx>>) -> &'tcx PredicateInner<'tcx> {
|
||||
fn intern_predicate(&self, binder: Binder<PredicateKind<'tcx>>) -> &'tcx PredicateInner<'tcx> {
|
||||
self.predicate
|
||||
.intern(binder, |binder| {
|
||||
let flags = super::flags::FlagComputation::for_predicate(binder);
|
||||
@ -1948,8 +1948,8 @@ impl<'tcx> Hash for Interned<'tcx, PredicateInner<'tcx>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Borrow<Binder<PredicateAtom<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
|
||||
fn borrow<'a>(&'a self) -> &'a Binder<PredicateAtom<'tcx>> {
|
||||
impl<'tcx> Borrow<Binder<PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
|
||||
fn borrow<'a>(&'a self) -> &'a Binder<PredicateKind<'tcx>> {
|
||||
&self.0.binder
|
||||
}
|
||||
}
|
||||
@ -2085,7 +2085,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_predicate(self, binder: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx> {
|
||||
pub fn mk_predicate(self, binder: Binder<PredicateKind<'tcx>>) -> Predicate<'tcx> {
|
||||
let inner = self.interners.intern_predicate(binder);
|
||||
Predicate { inner }
|
||||
}
|
||||
@ -2094,9 +2094,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn reuse_or_mk_predicate(
|
||||
self,
|
||||
pred: Predicate<'tcx>,
|
||||
binder: Binder<PredicateAtom<'tcx>>,
|
||||
binder: Binder<PredicateKind<'tcx>>,
|
||||
) -> Predicate<'tcx> {
|
||||
if pred.bound_atom() != binder { self.mk_predicate(binder) } else { pred }
|
||||
if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
|
||||
}
|
||||
|
||||
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {
|
||||
|
@ -22,7 +22,7 @@ impl FlagComputation {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn for_predicate(binder: ty::Binder<ty::PredicateAtom<'_>>) -> FlagComputation {
|
||||
pub fn for_predicate(binder: ty::Binder<ty::PredicateKind<'_>>) -> FlagComputation {
|
||||
let mut result = FlagComputation::new();
|
||||
result.add_predicate(binder);
|
||||
result
|
||||
@ -204,46 +204,46 @@ impl FlagComputation {
|
||||
}
|
||||
}
|
||||
|
||||
fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateAtom<'_>>) {
|
||||
fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateKind<'_>>) {
|
||||
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
|
||||
}
|
||||
|
||||
fn add_predicate_atom(&mut self, atom: ty::PredicateAtom<'_>) {
|
||||
fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) {
|
||||
match atom {
|
||||
ty::PredicateAtom::Trait(trait_pred, _constness) => {
|
||||
ty::PredicateKind::Trait(trait_pred, _constness) => {
|
||||
self.add_substs(trait_pred.trait_ref.substs);
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => {
|
||||
self.add_region(a);
|
||||
self.add_region(b);
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, region)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region)) => {
|
||||
self.add_ty(ty);
|
||||
self.add_region(region);
|
||||
}
|
||||
ty::PredicateAtom::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
|
||||
ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
|
||||
self.add_ty(a);
|
||||
self.add_ty(b);
|
||||
}
|
||||
ty::PredicateAtom::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
|
||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
|
||||
self.add_projection_ty(projection_ty);
|
||||
self.add_ty(ty);
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(arg) => {
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
self.add_substs(slice::from_ref(&arg));
|
||||
}
|
||||
ty::PredicateAtom::ObjectSafe(_def_id) => {}
|
||||
ty::PredicateAtom::ClosureKind(_def_id, substs, _kind) => {
|
||||
ty::PredicateKind::ObjectSafe(_def_id) => {}
|
||||
ty::PredicateKind::ClosureKind(_def_id, substs, _kind) => {
|
||||
self.add_substs(substs);
|
||||
}
|
||||
ty::PredicateAtom::ConstEvaluatable(_def_id, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(_def_id, substs) => {
|
||||
self.add_substs(substs);
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(expected, found) => {
|
||||
ty::PredicateKind::ConstEquate(expected, found) => {
|
||||
self.add_const(expected);
|
||||
self.add_const(found);
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
self.add_ty(ty);
|
||||
}
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ impl<'tcx> GenericPredicates<'tcx> {
|
||||
|
||||
#[derive(Debug)]
|
||||
crate struct PredicateInner<'tcx> {
|
||||
binder: Binder<PredicateAtom<'tcx>>,
|
||||
binder: Binder<PredicateKind<'tcx>>,
|
||||
flags: TypeFlags,
|
||||
/// See the comment for the corresponding field of [TyS].
|
||||
outer_exclusive_binder: ty::DebruijnIndex,
|
||||
@ -1060,23 +1060,13 @@ impl Hash for Predicate<'_> {
|
||||
impl<'tcx> Eq for Predicate<'tcx> {}
|
||||
|
||||
impl<'tcx> Predicate<'tcx> {
|
||||
/// Returns the inner `PredicateAtom`.
|
||||
///
|
||||
/// The returned atom may contain unbound variables bound to binders skipped in this method.
|
||||
/// It is safe to reapply binders to the given atom.
|
||||
///
|
||||
/// Note that this method panics in case this predicate has unbound variables.
|
||||
pub fn skip_binders(self) -> PredicateAtom<'tcx> {
|
||||
self.inner.binder.skip_binder()
|
||||
}
|
||||
|
||||
/// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an
|
||||
/// Converts this to a `Binder<PredicateKind<'tcx>>`. If the value was an
|
||||
/// `Atom`, then it is not allowed to contain escaping bound vars.
|
||||
pub fn bound_atom(self) -> Binder<PredicateAtom<'tcx>> {
|
||||
pub fn kind(self) -> Binder<PredicateKind<'tcx>> {
|
||||
self.inner.binder
|
||||
}
|
||||
|
||||
pub fn bound_atom_ref(self) -> &'tcx Binder<PredicateAtom<'tcx>> {
|
||||
pub fn kind_ref(self) -> &'tcx Binder<PredicateKind<'tcx>> {
|
||||
&self.inner.binder
|
||||
}
|
||||
}
|
||||
@ -1098,7 +1088,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||
#[derive(HashStable, TypeFoldable)]
|
||||
pub enum PredicateAtom<'tcx> {
|
||||
pub enum PredicateKind<'tcx> {
|
||||
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
|
||||
/// the `Self` type of the trait reference and `A`, `B`, and `C`
|
||||
/// would be the type parameters.
|
||||
@ -1229,7 +1219,7 @@ impl<'tcx> Predicate<'tcx> {
|
||||
// from the substitution and the value being substituted into, and
|
||||
// this trick achieves that).
|
||||
let substs = trait_ref.skip_binder().substs;
|
||||
let pred = self.skip_binders();
|
||||
let pred = self.kind().skip_binder();
|
||||
let new = pred.subst(tcx, substs);
|
||||
if new != pred { ty::Binder::bind(new).to_predicate(tcx) } else { self }
|
||||
}
|
||||
@ -1352,14 +1342,14 @@ pub trait ToPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx>;
|
||||
}
|
||||
|
||||
impl ToPredicate<'tcx> for Binder<PredicateAtom<'tcx>> {
|
||||
impl ToPredicate<'tcx> for Binder<PredicateKind<'tcx>> {
|
||||
#[inline(always)]
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
tcx.mk_predicate(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPredicate<'tcx> for PredicateAtom<'tcx> {
|
||||
impl ToPredicate<'tcx> for PredicateKind<'tcx> {
|
||||
#[inline(always)]
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
debug_assert!(!self.has_escaping_bound_vars(), "escaping bound vars for {:?}", self);
|
||||
@ -1369,7 +1359,7 @@ impl ToPredicate<'tcx> for PredicateAtom<'tcx> {
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
PredicateAtom::Trait(ty::TraitPredicate { trait_ref: self.value }, self.constness)
|
||||
PredicateKind::Trait(ty::TraitPredicate { trait_ref: self.value }, self.constness)
|
||||
.to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
@ -1386,62 +1376,62 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitPredicate<'tcx>> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.value.map_bound(|value| PredicateAtom::Trait(value, self.constness)).to_predicate(tcx)
|
||||
self.value.map_bound(|value| PredicateKind::Trait(value, self.constness)).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(PredicateAtom::RegionOutlives).to_predicate(tcx)
|
||||
self.map_bound(PredicateKind::RegionOutlives).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(PredicateAtom::TypeOutlives).to_predicate(tcx)
|
||||
self.map_bound(PredicateKind::TypeOutlives).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(PredicateAtom::Projection).to_predicate(tcx)
|
||||
self.map_bound(PredicateKind::Projection).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Predicate<'tcx> {
|
||||
pub fn to_opt_poly_trait_ref(self) -> Option<ConstnessAnd<PolyTraitRef<'tcx>>> {
|
||||
let predicate = self.bound_atom();
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateAtom::Trait(t, constness) => {
|
||||
PredicateKind::Trait(t, constness) => {
|
||||
Some(ConstnessAnd { constness, value: predicate.rebind(t.trait_ref) })
|
||||
}
|
||||
PredicateAtom::Projection(..)
|
||||
| PredicateAtom::Subtype(..)
|
||||
| PredicateAtom::RegionOutlives(..)
|
||||
| PredicateAtom::WellFormed(..)
|
||||
| PredicateAtom::ObjectSafe(..)
|
||||
| PredicateAtom::ClosureKind(..)
|
||||
| PredicateAtom::TypeOutlives(..)
|
||||
| PredicateAtom::ConstEvaluatable(..)
|
||||
| PredicateAtom::ConstEquate(..)
|
||||
| PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
PredicateKind::Projection(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::RegionOutlives(..)
|
||||
| PredicateKind::WellFormed(..)
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::ClosureKind(..)
|
||||
| PredicateKind::TypeOutlives(..)
|
||||
| PredicateKind::ConstEvaluatable(..)
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
|
||||
let predicate = self.bound_atom();
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateAtom::TypeOutlives(data) => Some(predicate.rebind(data)),
|
||||
PredicateAtom::Trait(..)
|
||||
| PredicateAtom::Projection(..)
|
||||
| PredicateAtom::Subtype(..)
|
||||
| PredicateAtom::RegionOutlives(..)
|
||||
| PredicateAtom::WellFormed(..)
|
||||
| PredicateAtom::ObjectSafe(..)
|
||||
| PredicateAtom::ClosureKind(..)
|
||||
| PredicateAtom::ConstEvaluatable(..)
|
||||
| PredicateAtom::ConstEquate(..)
|
||||
| PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
PredicateKind::TypeOutlives(data) => Some(predicate.rebind(data)),
|
||||
PredicateKind::Trait(..)
|
||||
| PredicateKind::Projection(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::RegionOutlives(..)
|
||||
| PredicateKind::WellFormed(..)
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::ClosureKind(..)
|
||||
| PredicateKind::ConstEvaluatable(..)
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -627,8 +627,8 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// may contain unbound variables. We therefore do this manually.
|
||||
//
|
||||
// FIXME(lcnr): Find out why exactly this is the case :)
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
if let ty::PredicateAtom::Trait(pred, _) = bound_predicate.skip_binder() {
|
||||
let bound_predicate = predicate.kind();
|
||||
if let ty::PredicateKind::Trait(pred, _) = bound_predicate.skip_binder() {
|
||||
let trait_ref = bound_predicate.rebind(pred.trait_ref);
|
||||
// Don't print +Sized, but rather +?Sized if absent.
|
||||
if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() {
|
||||
@ -2068,38 +2068,38 @@ define_print_and_forward_display! {
|
||||
}
|
||||
|
||||
ty::Predicate<'tcx> {
|
||||
let binder = self.bound_atom();
|
||||
let binder = self.kind();
|
||||
p!(print(binder))
|
||||
}
|
||||
|
||||
ty::PredicateAtom<'tcx> {
|
||||
ty::PredicateKind<'tcx> {
|
||||
match *self {
|
||||
ty::PredicateAtom::Trait(ref data, constness) => {
|
||||
ty::PredicateKind::Trait(ref data, constness) => {
|
||||
if let hir::Constness::Const = constness {
|
||||
p!("const ");
|
||||
}
|
||||
p!(print(data))
|
||||
}
|
||||
ty::PredicateAtom::Subtype(predicate) => p!(print(predicate)),
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => p!(print(predicate)),
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => p!(print(predicate)),
|
||||
ty::PredicateAtom::Projection(predicate) => p!(print(predicate)),
|
||||
ty::PredicateAtom::WellFormed(arg) => p!(print(arg), " well-formed"),
|
||||
ty::PredicateAtom::ObjectSafe(trait_def_id) => {
|
||||
ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
|
||||
ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)),
|
||||
ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)),
|
||||
ty::PredicateKind::Projection(predicate) => p!(print(predicate)),
|
||||
ty::PredicateKind::WellFormed(arg) => p!(print(arg), " well-formed"),
|
||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe")
|
||||
}
|
||||
ty::PredicateAtom::ClosureKind(closure_def_id, _closure_substs, kind) => {
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, _closure_substs, kind) => {
|
||||
p!("the closure `",
|
||||
print_value_path(closure_def_id, &[]),
|
||||
write("` implements the trait `{}`", kind))
|
||||
}
|
||||
ty::PredicateAtom::ConstEvaluatable(def, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(def, substs) => {
|
||||
p!("the constant `", print_value_path(def.did, substs), "` can be evaluated")
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
p!("the constant `", print(c1), "` equals `", print(c2), "`")
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
p!("the type `", print(ty), "` is found in the environment")
|
||||
}
|
||||
}
|
||||
|
@ -224,35 +224,35 @@ impl fmt::Debug for ty::ProjectionPredicate<'tcx> {
|
||||
|
||||
impl fmt::Debug for ty::Predicate<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self.bound_atom())
|
||||
write!(f, "{:?}", self.kind())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ty::PredicateAtom<'tcx> {
|
||||
impl fmt::Debug for ty::PredicateKind<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
ty::PredicateAtom::Trait(ref a, constness) => {
|
||||
ty::PredicateKind::Trait(ref a, constness) => {
|
||||
if let hir::Constness::Const = constness {
|
||||
write!(f, "const ")?;
|
||||
}
|
||||
a.fmt(f)
|
||||
}
|
||||
ty::PredicateAtom::Subtype(ref pair) => pair.fmt(f),
|
||||
ty::PredicateAtom::RegionOutlives(ref pair) => pair.fmt(f),
|
||||
ty::PredicateAtom::TypeOutlives(ref pair) => pair.fmt(f),
|
||||
ty::PredicateAtom::Projection(ref pair) => pair.fmt(f),
|
||||
ty::PredicateAtom::WellFormed(data) => write!(f, "WellFormed({:?})", data),
|
||||
ty::PredicateAtom::ObjectSafe(trait_def_id) => {
|
||||
ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
|
||||
ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
|
||||
ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
|
||||
ty::PredicateKind::Projection(ref pair) => pair.fmt(f),
|
||||
ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
|
||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||
write!(f, "ObjectSafe({:?})", trait_def_id)
|
||||
}
|
||||
ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
write!(f, "ClosureKind({:?}, {:?}, {:?})", closure_def_id, closure_substs, kind)
|
||||
}
|
||||
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
|
||||
write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
write!(f, "TypeWellFormedFromEnv({:?})", ty)
|
||||
}
|
||||
}
|
||||
@ -472,40 +472,40 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialProjection<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lift<'tcx> for ty::PredicateAtom<'a> {
|
||||
type Lifted = ty::PredicateAtom<'tcx>;
|
||||
impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
|
||||
type Lifted = ty::PredicateKind<'tcx>;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
match self {
|
||||
ty::PredicateAtom::Trait(data, constness) => {
|
||||
tcx.lift(data).map(|data| ty::PredicateAtom::Trait(data, constness))
|
||||
ty::PredicateKind::Trait(data, constness) => {
|
||||
tcx.lift(data).map(|data| ty::PredicateKind::Trait(data, constness))
|
||||
}
|
||||
ty::PredicateAtom::Subtype(data) => tcx.lift(data).map(ty::PredicateAtom::Subtype),
|
||||
ty::PredicateAtom::RegionOutlives(data) => {
|
||||
tcx.lift(data).map(ty::PredicateAtom::RegionOutlives)
|
||||
ty::PredicateKind::Subtype(data) => tcx.lift(data).map(ty::PredicateKind::Subtype),
|
||||
ty::PredicateKind::RegionOutlives(data) => {
|
||||
tcx.lift(data).map(ty::PredicateKind::RegionOutlives)
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(data) => {
|
||||
tcx.lift(data).map(ty::PredicateAtom::TypeOutlives)
|
||||
ty::PredicateKind::TypeOutlives(data) => {
|
||||
tcx.lift(data).map(ty::PredicateKind::TypeOutlives)
|
||||
}
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
tcx.lift(data).map(ty::PredicateAtom::Projection)
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
tcx.lift(data).map(ty::PredicateKind::Projection)
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(ty) => tcx.lift(ty).map(ty::PredicateAtom::WellFormed),
|
||||
ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
ty::PredicateKind::WellFormed(ty) => tcx.lift(ty).map(ty::PredicateKind::WellFormed),
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
tcx.lift(closure_substs).map(|closure_substs| {
|
||||
ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind)
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind)
|
||||
})
|
||||
}
|
||||
ty::PredicateAtom::ObjectSafe(trait_def_id) => {
|
||||
Some(ty::PredicateAtom::ObjectSafe(trait_def_id))
|
||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||
Some(ty::PredicateKind::ObjectSafe(trait_def_id))
|
||||
}
|
||||
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
|
||||
tcx.lift(substs).map(|substs| ty::PredicateAtom::ConstEvaluatable(def_id, substs))
|
||||
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
|
||||
tcx.lift(substs).map(|substs| ty::PredicateKind::ConstEvaluatable(def_id, substs))
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
tcx.lift((c1, c2)).map(|(c1, c2)| ty::PredicateAtom::ConstEquate(c1, c2))
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
tcx.lift((c1, c2)).map(|(c1, c2)| ty::PredicateKind::ConstEquate(c1, c2))
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
|
||||
tcx.lift(ty).map(ty::PredicateAtom::TypeWellFormedFromEnv)
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
tcx.lift(ty).map(ty::PredicateKind::TypeWellFormedFromEnv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -590,8 +590,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
|
||||
let mut found = false;
|
||||
for (bound, _) in bounds {
|
||||
if let ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(_, r)) =
|
||||
bound.skip_binders()
|
||||
if let ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_, r)) =
|
||||
bound.kind().skip_binder()
|
||||
{
|
||||
let r = r.subst(self.infcx.tcx, substs);
|
||||
if let ty::RegionKind::ReStatic = r {
|
||||
|
@ -1014,7 +1014,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
}
|
||||
|
||||
self.prove_predicate(
|
||||
ty::PredicateAtom::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
|
||||
ty::PredicateKind::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
|
||||
Locations::All(span),
|
||||
ConstraintCategory::TypeAnnotation,
|
||||
);
|
||||
@ -1266,7 +1266,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
obligations.obligations.push(traits::Obligation::new(
|
||||
ObligationCause::dummy(),
|
||||
param_env,
|
||||
ty::PredicateAtom::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
|
||||
ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
|
||||
));
|
||||
obligations.add(
|
||||
infcx
|
||||
@ -1611,7 +1611,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
self.check_call_dest(body, term, &sig, destination, term_location);
|
||||
|
||||
self.prove_predicates(
|
||||
sig.inputs_and_output.iter().map(|ty| ty::PredicateAtom::WellFormed(ty.into())),
|
||||
sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())),
|
||||
term_location.to_locations(),
|
||||
ConstraintCategory::Boring,
|
||||
);
|
||||
@ -2694,7 +2694,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
category: ConstraintCategory,
|
||||
) {
|
||||
self.prove_predicates(
|
||||
Some(ty::PredicateAtom::Trait(
|
||||
Some(ty::PredicateKind::Trait(
|
||||
ty::TraitPredicate { trait_ref },
|
||||
hir::Constness::NotConst,
|
||||
)),
|
||||
|
@ -411,24 +411,24 @@ impl Validator<'mir, 'tcx> {
|
||||
loop {
|
||||
let predicates = tcx.predicates_of(current);
|
||||
for (predicate, _) in predicates.predicates {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::RegionOutlives(_)
|
||||
| ty::PredicateAtom::TypeOutlives(_)
|
||||
| ty::PredicateAtom::WellFormed(_)
|
||||
| ty::PredicateAtom::Projection(_)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateAtom::ObjectSafe(_) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(_)
|
||||
| ty::PredicateKind::TypeOutlives(_)
|
||||
| ty::PredicateKind::WellFormed(_)
|
||||
| ty::PredicateKind::Projection(_)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateKind::ObjectSafe(_) => {
|
||||
bug!("object safe predicate on function: {:#?}", predicate)
|
||||
}
|
||||
ty::PredicateAtom::ClosureKind(..) => {
|
||||
ty::PredicateKind::ClosureKind(..) => {
|
||||
bug!("closure kind predicate on function: {:#?}", predicate)
|
||||
}
|
||||
ty::PredicateAtom::Subtype(_) => {
|
||||
ty::PredicateKind::Subtype(_) => {
|
||||
bug!("subtype predicate on function: {:#?}", predicate)
|
||||
}
|
||||
ty::PredicateAtom::Trait(pred, constness) => {
|
||||
ty::PredicateKind::Trait(pred, constness) => {
|
||||
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
||||
continue;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{
|
||||
self,
|
||||
subst::{GenericArgKind, Subst, SubstsRef},
|
||||
PredicateAtom, Ty, TyCtxt, TyS,
|
||||
PredicateKind, Ty, TyCtxt, TyS,
|
||||
};
|
||||
use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES;
|
||||
use rustc_span::{symbol::sym, Span};
|
||||
@ -105,7 +105,7 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
|
||||
let param_env = self.tcx.param_env(def_id);
|
||||
let bounds = param_env.caller_bounds();
|
||||
for bound in bounds {
|
||||
if let Some(bound_ty) = self.is_pointer_trait(&bound.skip_binders()) {
|
||||
if let Some(bound_ty) = self.is_pointer_trait(&bound.kind().skip_binder()) {
|
||||
// Get the argument types as they appear in the function signature.
|
||||
let arg_defs = self.tcx.fn_sig(def_id).skip_binder().inputs();
|
||||
for (arg_num, arg_def) in arg_defs.iter().enumerate() {
|
||||
@ -131,8 +131,8 @@ impl<'a, 'tcx> FunctionItemRefChecker<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
||||
fn is_pointer_trait(&self, bound: &PredicateAtom<'tcx>) -> Option<Ty<'tcx>> {
|
||||
if let ty::PredicateAtom::Trait(predicate, _) = bound {
|
||||
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
||||
if let ty::PredicateKind::Trait(predicate, _) = bound {
|
||||
if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) {
|
||||
Some(predicate.trait_ref.self_ty())
|
||||
} else {
|
||||
|
@ -100,19 +100,19 @@ where
|
||||
}
|
||||
|
||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(ty::TraitPredicate { trait_ref }, _) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(ty::TraitPredicate { trait_ref }, _) => {
|
||||
self.visit_trait(trait_ref)
|
||||
}
|
||||
ty::PredicateAtom::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
|
||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => {
|
||||
ty.visit_with(self)?;
|
||||
self.visit_trait(projection_ty.trait_ref(self.def_id_visitor.tcx()))
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _region)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _region)) => {
|
||||
ty.visit_with(self)
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(..) => ControlFlow::CONTINUE,
|
||||
ty::PredicateAtom::ConstEvaluatable(..)
|
||||
ty::PredicateKind::RegionOutlives(..) => ControlFlow::CONTINUE,
|
||||
ty::PredicateKind::ConstEvaluatable(..)
|
||||
if self.def_id_visitor.tcx().features().const_evaluatable_checked =>
|
||||
{
|
||||
// FIXME(const_evaluatable_checked): If the constant used here depends on a
|
||||
|
@ -1153,7 +1153,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
||||
debug!("instantiate_opaque_types: ty_var={:?}", ty_var);
|
||||
|
||||
for predicate in &bounds {
|
||||
if let ty::PredicateAtom::Projection(projection) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
|
||||
if projection.ty.references_error() {
|
||||
// No point on adding these obligations since there's a type error involved.
|
||||
return ty_var;
|
||||
@ -1251,18 +1251,18 @@ crate fn required_region_bounds(
|
||||
traits::elaborate_predicates(tcx, predicates)
|
||||
.filter_map(|obligation| {
|
||||
debug!("required_region_bounds(obligation={:?})", obligation);
|
||||
match obligation.predicate.skip_binders() {
|
||||
ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::RegionOutlives(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
|
||||
match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
|
||||
// Search for a bound of the form `erased_self_ty
|
||||
// : 'a`, but be wary of something like `for<'a>
|
||||
// erased_self_ty : 'a` (we interpret a
|
||||
|
@ -414,9 +414,9 @@ impl AutoTraitFinder<'tcx> {
|
||||
let mut should_add_new = true;
|
||||
user_computed_preds.retain(|&old_pred| {
|
||||
if let (
|
||||
ty::PredicateAtom::Trait(new_trait, _),
|
||||
ty::PredicateAtom::Trait(old_trait, _),
|
||||
) = (new_pred.skip_binders(), old_pred.skip_binders())
|
||||
ty::PredicateKind::Trait(new_trait, _),
|
||||
ty::PredicateKind::Trait(old_trait, _),
|
||||
) = (new_pred.kind().skip_binder(), old_pred.kind().skip_binder())
|
||||
{
|
||||
if new_trait.def_id() == old_trait.def_id() {
|
||||
let new_substs = new_trait.trait_ref.substs;
|
||||
@ -633,16 +633,16 @@ impl AutoTraitFinder<'tcx> {
|
||||
// We check this by calling is_of_param on the relevant types
|
||||
// from the various possible predicates
|
||||
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
let bound_predicate = predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(p, _) => {
|
||||
ty::PredicateKind::Trait(p, _) => {
|
||||
// Add this to `predicates` so that we end up calling `select`
|
||||
// with it. If this predicate ends up being unimplemented,
|
||||
// then `evaluate_predicates` will handle adding it the `ParamEnv`
|
||||
// if possible.
|
||||
predicates.push_back(bound_predicate.rebind(p));
|
||||
}
|
||||
ty::PredicateAtom::Projection(p) => {
|
||||
ty::PredicateKind::Projection(p) => {
|
||||
let p = bound_predicate.rebind(p);
|
||||
debug!(
|
||||
"evaluate_nested_obligations: examining projection predicate {:?}",
|
||||
@ -772,13 +772,13 @@ impl AutoTraitFinder<'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(binder) => {
|
||||
ty::PredicateKind::RegionOutlives(binder) => {
|
||||
let binder = bound_predicate.rebind(binder);
|
||||
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(binder) => {
|
||||
ty::PredicateKind::TypeOutlives(binder) => {
|
||||
let binder = bound_predicate.rebind(binder);
|
||||
match (
|
||||
binder.no_bound_vars(),
|
||||
@ -801,7 +801,7 @@ impl AutoTraitFinder<'tcx> {
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
let evaluate = |c: &'tcx ty::Const<'tcx>| {
|
||||
if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val {
|
||||
match select.infcx().const_eval_resolve(
|
||||
|
@ -41,8 +41,8 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
||||
// We are looking at a generic abstract constant.
|
||||
Some(ct) => {
|
||||
for pred in param_env.caller_bounds() {
|
||||
match pred.skip_binders() {
|
||||
ty::PredicateAtom::ConstEvaluatable(b_def, b_substs) => {
|
||||
match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::ConstEvaluatable(b_def, b_substs) => {
|
||||
debug!(
|
||||
"is_const_evaluatable: caller_bound={:?}, {:?}",
|
||||
b_def, b_substs
|
||||
|
@ -256,9 +256,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(trait_predicate, _) => {
|
||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
||||
let trait_predicate = bound_predicate.rebind(trait_predicate);
|
||||
let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
|
||||
|
||||
@ -517,14 +517,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
err
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Subtype(predicate) => {
|
||||
ty::PredicateKind::Subtype(predicate) => {
|
||||
// Errors for Subtype predicates show up as
|
||||
// `FulfillmentErrorCode::CodeSubtypeError`,
|
||||
// not selection error.
|
||||
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
let predicate = bound_predicate.rebind(predicate);
|
||||
let predicate = self.resolve_vars_if_possible(predicate);
|
||||
let err = self
|
||||
@ -541,7 +541,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Projection(..) | ty::PredicateAtom::TypeOutlives(..) => {
|
||||
ty::PredicateKind::Projection(..) | ty::PredicateKind::TypeOutlives(..) => {
|
||||
let predicate = self.resolve_vars_if_possible(obligation.predicate);
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
@ -552,12 +552,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(trait_def_id) => {
|
||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||
let violations = self.tcx.object_safety_violations(trait_def_id);
|
||||
report_object_safety_error(self.tcx, span, trait_def_id, violations)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
|
||||
let found_kind = self.closure_kind(closure_substs).unwrap();
|
||||
let closure_span =
|
||||
self.tcx.sess.source_map().guess_head_span(
|
||||
@ -617,7 +617,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
ty::PredicateAtom::WellFormed(ty) => {
|
||||
ty::PredicateKind::WellFormed(ty) => {
|
||||
if !self.tcx.sess.opts.debugging_opts.chalk {
|
||||
// WF predicates cannot themselves make
|
||||
// errors. They can only block due to
|
||||
@ -635,7 +635,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ConstEvaluatable(..) => {
|
||||
ty::PredicateKind::ConstEvaluatable(..) => {
|
||||
// Errors for `ConstEvaluatable` predicates show up as
|
||||
// `SelectionError::ConstEvalFailure`,
|
||||
// not `Unimplemented`.
|
||||
@ -646,7 +646,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ConstEquate(..) => {
|
||||
ty::PredicateKind::ConstEquate(..) => {
|
||||
// Errors for `ConstEquate` predicates show up as
|
||||
// `SelectionError::ConstEvalFailure`,
|
||||
// not `Unimplemented`.
|
||||
@ -657,7 +657,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => span_bug!(
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => span_bug!(
|
||||
span,
|
||||
"TypeWellFormedFromEnv predicate should only exist in the environment"
|
||||
),
|
||||
@ -1069,9 +1069,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// FIXME: It should be possible to deal with `ForAll` in a cleaner way.
|
||||
let bound_error = error.bound_atom();
|
||||
let (cond, error) = match (cond.skip_binders(), bound_error.skip_binder()) {
|
||||
(ty::PredicateAtom::Trait(..), ty::PredicateAtom::Trait(error, _)) => {
|
||||
let bound_error = error.kind();
|
||||
let (cond, error) = match (cond.kind().skip_binder(), bound_error.skip_binder()) {
|
||||
(ty::PredicateKind::Trait(..), ty::PredicateKind::Trait(error, _)) => {
|
||||
(cond, bound_error.rebind(error))
|
||||
}
|
||||
_ => {
|
||||
@ -1081,8 +1081,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
};
|
||||
|
||||
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
if let ty::PredicateAtom::Trait(implication, _) = bound_predicate.skip_binder() {
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
if let ty::PredicateKind::Trait(implication, _) = bound_predicate.skip_binder() {
|
||||
let error = error.to_poly_trait_ref();
|
||||
let implication = bound_predicate.rebind(implication.trait_ref);
|
||||
// FIXME: I'm just not taking associated types at all here.
|
||||
@ -1162,8 +1162,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
//
|
||||
// this can fail if the problem was higher-ranked, in which
|
||||
// cause I have no idea for a good error message.
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
if let ty::PredicateAtom::Projection(data) = bound_predicate.skip_binder() {
|
||||
let bound_predicate = predicate.kind();
|
||||
if let ty::PredicateKind::Projection(data) = bound_predicate.skip_binder() {
|
||||
let mut selcx = SelectionContext::new(self);
|
||||
let (data, _) = self.replace_bound_vars_with_fresh_vars(
|
||||
obligation.cause.span,
|
||||
@ -1452,9 +1452,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
let bound_predicate = predicate.kind();
|
||||
let mut err = match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(data, _) => {
|
||||
ty::PredicateKind::Trait(data, _) => {
|
||||
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
||||
debug!("trait_ref {:?}", trait_ref);
|
||||
|
||||
@ -1559,7 +1559,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
err
|
||||
}
|
||||
|
||||
ty::PredicateAtom::WellFormed(arg) => {
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
// Same hacky approach as above to avoid deluging user
|
||||
// with error messages.
|
||||
if arg.references_error() || self.tcx.sess.has_errors() {
|
||||
@ -1569,7 +1569,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
self.emit_inference_failure_err(body_id, span, arg, ErrorCode::E0282)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Subtype(data) => {
|
||||
ty::PredicateKind::Subtype(data) => {
|
||||
if data.references_error() || self.tcx.sess.has_errors() {
|
||||
// no need to overload user in such cases
|
||||
return;
|
||||
@ -1579,7 +1579,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
assert!(a.is_ty_var() && b.is_ty_var());
|
||||
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282)
|
||||
}
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
let trait_ref = bound_predicate.rebind(data).to_poly_trait_ref(self.tcx);
|
||||
let self_ty = trait_ref.skip_binder().self_ty();
|
||||
let ty = data.ty;
|
||||
@ -1709,9 +1709,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
let (pred, item_def_id, span) =
|
||||
match (obligation.predicate.skip_binders(), obligation.cause.code.peel_derives()) {
|
||||
match (obligation.predicate.kind().skip_binder(), obligation.cause.code.peel_derives())
|
||||
{
|
||||
(
|
||||
ty::PredicateAtom::Trait(pred, _),
|
||||
ty::PredicateKind::Trait(pred, _),
|
||||
&ObligationCauseCode::BindingObligation(item_def_id, span),
|
||||
) => (pred, item_def_id, span),
|
||||
_ => return,
|
||||
|
@ -1292,8 +1292,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
// the type. The last generator (`outer_generator` below) has information about where the
|
||||
// bound was introduced. At least one generator should be present for this diagnostic to be
|
||||
// modified.
|
||||
let (mut trait_ref, mut target_ty) = match obligation.predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())),
|
||||
let (mut trait_ref, mut target_ty) = match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())),
|
||||
_ => (None, None),
|
||||
};
|
||||
let mut generator = None;
|
||||
|
@ -345,13 +345,13 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
|
||||
let infcx = self.selcx.infcx();
|
||||
|
||||
let binder = obligation.predicate.bound_atom();
|
||||
if binder.skip_binder().has_escaping_bound_vars() {
|
||||
match binder.skip_binder() {
|
||||
let binder = obligation.predicate.kind();
|
||||
match binder.no_bound_vars() {
|
||||
None => match binder.skip_binder() {
|
||||
// Evaluation will discard candidates using the leak check.
|
||||
// This means we need to pass it the bound version of our
|
||||
// predicate.
|
||||
ty::PredicateAtom::Trait(trait_ref, _constness) => {
|
||||
ty::PredicateKind::Trait(trait_ref, _constness) => {
|
||||
let trait_obligation = obligation.with(binder.rebind(trait_ref));
|
||||
|
||||
self.process_trait_obligation(
|
||||
@ -360,7 +360,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
&mut pending_obligation.stalled_on,
|
||||
)
|
||||
}
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
let project_obligation = obligation.with(binder.rebind(data));
|
||||
|
||||
self.process_projection_obligation(
|
||||
@ -368,26 +368,25 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
&mut pending_obligation.stalled_on,
|
||||
)
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(_)
|
||||
| ty::PredicateAtom::TypeOutlives(_)
|
||||
| ty::PredicateAtom::WellFormed(_)
|
||||
| ty::PredicateAtom::ObjectSafe(_)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(_)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..) => {
|
||||
ty::PredicateKind::RegionOutlives(_)
|
||||
| ty::PredicateKind::TypeOutlives(_)
|
||||
| ty::PredicateKind::WellFormed(_)
|
||||
| ty::PredicateKind::ObjectSafe(_)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(_)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..) => {
|
||||
let pred = infcx.replace_bound_vars_with_placeholders(binder);
|
||||
ProcessResult::Changed(mk_pending(vec![
|
||||
obligation.with(pred.to_predicate(self.selcx.tcx())),
|
||||
]))
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match binder.skip_binder() {
|
||||
ty::PredicateAtom::Trait(data, _) => {
|
||||
},
|
||||
Some(pred) => match pred {
|
||||
ty::PredicateKind::Trait(data, _) => {
|
||||
let trait_obligation = obligation.with(Binder::dummy(data));
|
||||
|
||||
self.process_trait_obligation(
|
||||
@ -397,14 +396,14 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(data) => {
|
||||
ty::PredicateKind::RegionOutlives(data) => {
|
||||
match infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data)) {
|
||||
Ok(()) => ProcessResult::Changed(vec![]),
|
||||
Err(_) => ProcessResult::Error(CodeSelectionError(Unimplemented)),
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(t_a, r_b)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t_a, r_b)) => {
|
||||
if self.register_region_obligations {
|
||||
self.selcx.infcx().register_region_obligation_with_cause(
|
||||
t_a,
|
||||
@ -415,7 +414,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
ProcessResult::Changed(vec![])
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Projection(ref data) => {
|
||||
ty::PredicateKind::Projection(ref data) => {
|
||||
let project_obligation = obligation.with(Binder::dummy(*data));
|
||||
|
||||
self.process_projection_obligation(
|
||||
@ -424,7 +423,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(trait_def_id) => {
|
||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||
if !self.selcx.tcx().is_object_safe(trait_def_id) {
|
||||
ProcessResult::Error(CodeSelectionError(Unimplemented))
|
||||
} else {
|
||||
@ -432,7 +431,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ClosureKind(_, closure_substs, kind) => {
|
||||
ty::PredicateKind::ClosureKind(_, closure_substs, kind) => {
|
||||
match self.selcx.infcx().closure_kind(closure_substs) {
|
||||
Some(closure_kind) => {
|
||||
if closure_kind.extends(kind) {
|
||||
@ -445,7 +444,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::WellFormed(arg) => {
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
match wf::obligations(
|
||||
self.selcx.infcx(),
|
||||
obligation.param_env,
|
||||
@ -463,7 +462,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Subtype(subtype) => {
|
||||
ty::PredicateKind::Subtype(subtype) => {
|
||||
match self.selcx.infcx().subtype_predicate(
|
||||
&obligation.cause,
|
||||
obligation.param_env,
|
||||
@ -489,7 +488,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
|
||||
match const_evaluatable::is_const_evaluatable(
|
||||
self.selcx.infcx(),
|
||||
def_id,
|
||||
@ -509,7 +508,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
debug!(?c1, ?c2, "equating consts");
|
||||
if self.selcx.tcx().features().const_evaluatable_checked {
|
||||
// FIXME: we probably should only try to unify abstract constants
|
||||
@ -595,10 +594,10 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ pub fn normalize_param_env_or_error<'tcx>(
|
||||
// TypeOutlives predicates - these are normally used by regionck.
|
||||
let outlives_predicates: Vec<_> = predicates
|
||||
.drain_filter(|predicate| {
|
||||
matches!(predicate.skip_binders(), ty::PredicateAtom::TypeOutlives(..))
|
||||
matches!(predicate.kind().skip_binder(), ty::PredicateKind::TypeOutlives(..))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -273,12 +273,12 @@ fn predicate_references_self(
|
||||
) -> Option<Span> {
|
||||
let self_ty = tcx.types.self_param;
|
||||
let has_self_ty = |arg: &GenericArg<'_>| arg.walk().any(|arg| arg == self_ty.into());
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(ref data, _) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(ref data, _) => {
|
||||
// In the case of a trait predicate, we can skip the "self" type.
|
||||
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
||||
}
|
||||
ty::PredicateAtom::Projection(ref data) => {
|
||||
ty::PredicateKind::Projection(ref data) => {
|
||||
// And similarly for projections. This should be redundant with
|
||||
// the previous check because any projection should have a
|
||||
// matching `Trait` predicate with the same inputs, but we do
|
||||
@ -300,15 +300,15 @@ fn predicate_references_self(
|
||||
None
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::TypeOutlives(..)
|
||||
| ty::PredicateAtom::RegionOutlives(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::TypeOutlives(..)
|
||||
| ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,20 +328,20 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
let predicates = tcx.predicates_of(def_id);
|
||||
let predicates = predicates.instantiate_identity(tcx).predicates;
|
||||
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
|
||||
match obligation.predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(ref trait_pred, _) => {
|
||||
match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(ref trait_pred, _) => {
|
||||
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
|
||||
}
|
||||
ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::RegionOutlives(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::TypeOutlives(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => false,
|
||||
ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::TypeOutlives(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => false,
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -843,7 +843,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
|
||||
}
|
||||
|
||||
fn visit_predicate(&mut self, pred: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::PredicateAtom::ConstEvaluatable(def, substs) = pred.skip_binders() {
|
||||
if let ty::PredicateKind::ConstEvaluatable(def, substs) = pred.kind().skip_binder() {
|
||||
// FIXME(const_evaluatable_checked): We should probably deduplicate the logic for
|
||||
// `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to
|
||||
// take a `ty::Const` instead.
|
||||
|
@ -625,7 +625,7 @@ fn prune_cache_value_obligations<'a, 'tcx>(
|
||||
.obligations
|
||||
.iter()
|
||||
.filter(|obligation| {
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
// We found a `T: Foo<X = U>` predicate, let's check
|
||||
// if `U` references any unresolved type
|
||||
@ -636,7 +636,7 @@ fn prune_cache_value_obligations<'a, 'tcx>(
|
||||
// indirect obligations (e.g., we project to `?0`,
|
||||
// but we have `T: Foo<X = ?1>` and `?1: Bar<X =
|
||||
// ?0>`).
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
infcx.unresolved_type_vars(&bound_predicate.rebind(data.ty)).is_some()
|
||||
}
|
||||
|
||||
@ -917,8 +917,8 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
|
||||
let infcx = selcx.infcx();
|
||||
for predicate in env_predicates {
|
||||
debug!(?predicate);
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
if let ty::PredicateAtom::Projection(data) = predicate.skip_binders() {
|
||||
let bound_predicate = predicate.kind();
|
||||
if let ty::PredicateKind::Projection(data) = predicate.kind().skip_binder() {
|
||||
let data = bound_predicate.rebind(data);
|
||||
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id;
|
||||
|
||||
|
@ -15,7 +15,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
||||
// `&T`, accounts for about 60% percentage of the predicates
|
||||
// we have to prove. No need to canonicalize and all that for
|
||||
// such cases.
|
||||
if let ty::PredicateAtom::Trait(trait_ref, _) = key.value.predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Trait(trait_ref, _) = key.value.predicate.kind().skip_binder() {
|
||||
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
|
||||
if trait_ref.def_id() == sized_def_id {
|
||||
if trait_ref.self_ty().is_trivially_sized(tcx) {
|
||||
|
@ -432,7 +432,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
.predicates
|
||||
.into_iter()
|
||||
{
|
||||
if let ty::PredicateAtom::Trait(..) = super_trait.skip_binders() {
|
||||
if let ty::PredicateKind::Trait(..) = super_trait.kind().skip_binder() {
|
||||
let normalized_super_trait = normalize_with_depth_to(
|
||||
self,
|
||||
obligation.param_env,
|
||||
@ -641,7 +641,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
obligations.push(Obligation::new(
|
||||
obligation.cause.clone(),
|
||||
obligation.param_env,
|
||||
ty::PredicateAtom::ClosureKind(closure_def_id, substs, kind)
|
||||
ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)
|
||||
.to_predicate(self.tcx()),
|
||||
));
|
||||
}
|
||||
|
@ -454,16 +454,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
let result = ensure_sufficient_stack(|| {
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(t, _) => {
|
||||
ty::PredicateKind::Trait(t, _) => {
|
||||
let t = bound_predicate.rebind(t);
|
||||
debug_assert!(!t.has_escaping_bound_vars());
|
||||
let obligation = obligation.with(t);
|
||||
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Subtype(p) => {
|
||||
ty::PredicateKind::Subtype(p) => {
|
||||
let p = bound_predicate.rebind(p);
|
||||
// Does this code ever run?
|
||||
match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
|
||||
@ -479,7 +479,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::WellFormed(arg) => match wf::obligations(
|
||||
ty::PredicateKind::WellFormed(arg) => match wf::obligations(
|
||||
self.infcx,
|
||||
obligation.param_env,
|
||||
obligation.cause.body_id,
|
||||
@ -494,12 +494,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
None => Ok(EvaluatedToAmbig),
|
||||
},
|
||||
|
||||
ty::PredicateAtom::TypeOutlives(..) | ty::PredicateAtom::RegionOutlives(..) => {
|
||||
ty::PredicateKind::TypeOutlives(..) | ty::PredicateKind::RegionOutlives(..) => {
|
||||
// We do not consider region relationships when evaluating trait matches.
|
||||
Ok(EvaluatedToOkModuloRegions)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(trait_def_id) => {
|
||||
ty::PredicateKind::ObjectSafe(trait_def_id) => {
|
||||
if self.tcx().is_object_safe(trait_def_id) {
|
||||
Ok(EvaluatedToOk)
|
||||
} else {
|
||||
@ -507,7 +507,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
let data = bound_predicate.rebind(data);
|
||||
let project_obligation = obligation.with(data);
|
||||
match project::poly_project_and_unify_type(self, &project_obligation) {
|
||||
@ -528,7 +528,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ClosureKind(_, closure_substs, kind) => {
|
||||
ty::PredicateKind::ClosureKind(_, closure_substs, kind) => {
|
||||
match self.infcx.closure_kind(closure_substs) {
|
||||
Some(closure_kind) => {
|
||||
if closure_kind.extends(kind) {
|
||||
@ -541,7 +541,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
|
||||
match const_evaluatable::is_const_evaluatable(
|
||||
self.infcx,
|
||||
def_id,
|
||||
@ -555,7 +555,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
debug!(?c1, ?c2, "evaluate_predicate_recursively: equating consts");
|
||||
|
||||
let evaluate = |c: &'tcx ty::Const<'tcx>| {
|
||||
@ -598,7 +598,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("TypeWellFormedFromEnv is only used for chalk")
|
||||
}
|
||||
}
|
||||
@ -845,8 +845,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
let result = match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()),
|
||||
let result = match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()),
|
||||
_ => false,
|
||||
};
|
||||
debug!(?predicate, ?result, "coinductive_predicate");
|
||||
@ -1174,8 +1174,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(idx, bound)| {
|
||||
let bound_predicate = bound.bound_atom();
|
||||
if let ty::PredicateAtom::Trait(pred, _) = bound_predicate.skip_binder() {
|
||||
let bound_predicate = bound.kind();
|
||||
if let ty::PredicateKind::Trait(pred, _) = bound_predicate.skip_binder() {
|
||||
let bound = bound_predicate.rebind(pred.trait_ref);
|
||||
if self.infcx.probe(|_| {
|
||||
match self.match_normalize_trait_ref(
|
||||
|
@ -106,28 +106,28 @@ pub fn predicate_obligations<'a, 'tcx>(
|
||||
};
|
||||
|
||||
// It's ok to skip the binder here because wf code is prepared for it
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(t, _) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(t, _) => {
|
||||
wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(..) => {}
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
|
||||
ty::PredicateKind::RegionOutlives(..) => {}
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
|
||||
wf.compute(ty.into());
|
||||
}
|
||||
ty::PredicateAtom::Projection(t) => {
|
||||
ty::PredicateKind::Projection(t) => {
|
||||
wf.compute_projection(t.projection_ty);
|
||||
wf.compute(t.ty.into());
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(arg) => {
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
wf.compute(arg);
|
||||
}
|
||||
ty::PredicateAtom::ObjectSafe(_) => {}
|
||||
ty::PredicateAtom::ClosureKind(..) => {}
|
||||
ty::PredicateAtom::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => {
|
||||
ty::PredicateKind::ObjectSafe(_) => {}
|
||||
ty::PredicateKind::ClosureKind(..) => {}
|
||||
ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => {
|
||||
wf.compute(a.into());
|
||||
wf.compute(b.into());
|
||||
}
|
||||
ty::PredicateAtom::ConstEvaluatable(def, substs) => {
|
||||
ty::PredicateKind::ConstEvaluatable(def, substs) => {
|
||||
let obligations = wf.nominal_obligations(def.did, substs);
|
||||
wf.out.extend(obligations);
|
||||
|
||||
@ -135,11 +135,11 @@ pub fn predicate_obligations<'a, 'tcx>(
|
||||
wf.compute(arg);
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::ConstEquate(c1, c2) => {
|
||||
ty::PredicateKind::ConstEquate(c1, c2) => {
|
||||
wf.compute(c1.into());
|
||||
wf.compute(c2.into());
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("TypeWellFormedFromEnv is only used for Chalk")
|
||||
}
|
||||
}
|
||||
@ -209,8 +209,8 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||
};
|
||||
|
||||
// It is fine to skip the binder as we don't care about regions here.
|
||||
match pred.skip_binders() {
|
||||
ty::PredicateAtom::Projection(proj) => {
|
||||
match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Projection(proj) => {
|
||||
// The obligation comes not from the current `impl` nor the `trait` being implemented,
|
||||
// but rather from a "second order" obligation, where an associated type has a
|
||||
// projection coming from another associated type. See
|
||||
@ -225,7 +225,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::Trait(pred, _) => {
|
||||
ty::PredicateKind::Trait(pred, _) => {
|
||||
// An associated item obligation born out of the `trait` failed to be met. An example
|
||||
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
|
||||
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
|
||||
@ -343,7 +343,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
new_cause,
|
||||
depth,
|
||||
param_env,
|
||||
ty::PredicateAtom::WellFormed(arg).to_predicate(tcx),
|
||||
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
|
||||
)
|
||||
}),
|
||||
);
|
||||
@ -393,7 +393,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
cause.clone(),
|
||||
depth,
|
||||
param_env,
|
||||
ty::PredicateAtom::WellFormed(arg).to_predicate(tcx),
|
||||
ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
|
||||
)
|
||||
}),
|
||||
);
|
||||
@ -436,7 +436,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
let obligations = self.nominal_obligations(def.did, substs);
|
||||
self.out.extend(obligations);
|
||||
|
||||
let predicate = ty::PredicateAtom::ConstEvaluatable(def, substs)
|
||||
let predicate = ty::PredicateKind::ConstEvaluatable(def, substs)
|
||||
.to_predicate(self.tcx());
|
||||
let cause = self.cause(traits::MiscObligation);
|
||||
self.out.push(traits::Obligation::with_depth(
|
||||
@ -460,7 +460,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
cause,
|
||||
self.recursion_depth,
|
||||
self.param_env,
|
||||
ty::PredicateAtom::WellFormed(resolved_constant.into())
|
||||
ty::PredicateKind::WellFormed(resolved_constant.into())
|
||||
.to_predicate(self.tcx()),
|
||||
));
|
||||
}
|
||||
@ -547,7 +547,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
cause,
|
||||
depth,
|
||||
param_env,
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(rty, r))
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(rty, r))
|
||||
.to_predicate(self.tcx()),
|
||||
));
|
||||
}
|
||||
@ -637,7 +637,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
cause.clone(),
|
||||
depth,
|
||||
param_env,
|
||||
ty::PredicateAtom::ObjectSafe(did).to_predicate(tcx),
|
||||
ty::PredicateKind::ObjectSafe(did).to_predicate(tcx),
|
||||
)
|
||||
}));
|
||||
}
|
||||
@ -664,7 +664,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
cause,
|
||||
self.recursion_depth,
|
||||
param_env,
|
||||
ty::PredicateAtom::WellFormed(ty.into()).to_predicate(self.tcx()),
|
||||
ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()),
|
||||
));
|
||||
} else {
|
||||
// Yes, resolved, proceed with the result.
|
||||
|
@ -82,35 +82,35 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
||||
) -> chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'tcx>>> {
|
||||
let clauses = self.environment.into_iter().map(|predicate| {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, predicate.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, predicate.kind());
|
||||
let consequence = match predicate {
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateAtom::Trait(predicate, _) => chalk_ir::DomainGoal::FromEnv(
|
||||
ty::PredicateKind::Trait(predicate, _) => chalk_ir::DomainGoal::FromEnv(
|
||||
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
|
||||
),
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
}),
|
||||
),
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
ty::PredicateKind::TypeOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
}),
|
||||
),
|
||||
ty::PredicateAtom::Projection(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
ty::PredicateKind::Projection(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||
),
|
||||
ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..) => bug!("unexpected predicate {}", predicate),
|
||||
ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..) => bug!("unexpected predicate {}", predicate),
|
||||
};
|
||||
let value = chalk_ir::ProgramClauseImplication {
|
||||
consequence,
|
||||
@ -134,15 +134,15 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predicate<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
|
||||
let value = match predicate {
|
||||
ty::PredicateAtom::Trait(predicate, _) => {
|
||||
ty::PredicateKind::Trait(predicate, _) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
@ -150,7 +150,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||
}),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => {
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
@ -158,12 +158,12 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||
}),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::Projection(predicate) => {
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(arg) => match arg.unpack() {
|
||||
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => match ty.kind() {
|
||||
// FIXME(chalk): In Chalk, a placeholder is WellFormed if it
|
||||
// `FromEnv`. However, when we "lower" Params, we don't update
|
||||
@ -183,7 +183,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||
GenericArgKind::Lifetime(lt) => bug!("unexpect well formed predicate: {:?}", lt),
|
||||
},
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(t) => chalk_ir::GoalData::DomainGoal(
|
||||
ty::PredicateKind::ObjectSafe(t) => chalk_ir::GoalData::DomainGoal(
|
||||
chalk_ir::DomainGoal::ObjectSafe(chalk_ir::TraitId(t)),
|
||||
),
|
||||
|
||||
@ -191,13 +191,13 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||
//
|
||||
// We can defer this, but ultimately we'll want to express
|
||||
// some of these in terms of chalk operations.
|
||||
ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..) => {
|
||||
ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..) => {
|
||||
chalk_ir::GoalData::All(chalk_ir::Goals::empty(interner))
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => chalk_ir::GoalData::DomainGoal(
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => chalk_ir::GoalData::DomainGoal(
|
||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner))),
|
||||
),
|
||||
};
|
||||
@ -568,34 +568,34 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
||||
interner: &RustInterner<'tcx>,
|
||||
) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
let value = match predicate {
|
||||
ty::PredicateAtom::Trait(predicate, _) => {
|
||||
ty::PredicateKind::Trait(predicate, _) => {
|
||||
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
}))
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => {
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
Some(chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
}))
|
||||
}
|
||||
ty::PredicateAtom::Projection(predicate) => {
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(_ty) => None,
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("unexpected predicate {}", &self)
|
||||
}
|
||||
};
|
||||
@ -699,28 +699,28 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
|
||||
interner: &RustInterner<'tcx>,
|
||||
) -> Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
match predicate {
|
||||
ty::PredicateAtom::Trait(predicate, _) => Some(chalk_ir::Binders::new(
|
||||
ty::PredicateKind::Trait(predicate, _) => Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||
predicate.trait_ref.lower_into(interner),
|
||||
),
|
||||
)),
|
||||
ty::PredicateAtom::Projection(predicate) => Some(chalk_ir::Binders::new(
|
||||
ty::PredicateKind::Projection(predicate) => Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
||||
)),
|
||||
ty::PredicateAtom::TypeOutlives(_predicate) => None,
|
||||
ty::PredicateAtom::WellFormed(_ty) => None,
|
||||
ty::PredicateKind::TypeOutlives(_predicate) => None,
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("unexpected predicate {}", &self)
|
||||
}
|
||||
}
|
||||
|
@ -94,27 +94,27 @@ fn compute_implied_outlives_bounds<'tcx>(
|
||||
// region relationships.
|
||||
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
|
||||
assert!(!obligation.has_escaping_bound_vars());
|
||||
match obligation.predicate.bound_atom().no_bound_vars() {
|
||||
match obligation.predicate.kind().no_bound_vars() {
|
||||
None => vec![],
|
||||
Some(pred) => match pred {
|
||||
ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => vec![],
|
||||
ty::PredicateAtom::WellFormed(arg) => {
|
||||
ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => vec![],
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
wf_args.push(arg);
|
||||
vec![]
|
||||
}
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
vec![OutlivesBound::RegionSubRegion(r_b, r_a)]
|
||||
}
|
||||
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
|
||||
let ty_a = infcx.resolve_vars_if_possible(ty_a);
|
||||
let mut components = smallvec![];
|
||||
tcx.push_outlives_components(ty_a, &mut components);
|
||||
|
@ -46,16 +46,16 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>(
|
||||
}
|
||||
|
||||
fn not_outlives_predicate(p: &ty::Predicate<'tcx>) -> bool {
|
||||
match p.skip_binders() {
|
||||
ty::PredicateAtom::RegionOutlives(..) | ty::PredicateAtom::TypeOutlives(..) => false,
|
||||
ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => true,
|
||||
match p.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
|
||||
ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => true,
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
||||
self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
|
||||
|
||||
self.prove_predicate(
|
||||
ty::PredicateAtom::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
|
||||
ty::PredicateKind::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
|
||||
);
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
||||
// them? This would only be relevant if some input
|
||||
// type were ill-formed but did not appear in `ty`,
|
||||
// which...could happen with normalization...
|
||||
self.prove_predicate(ty::PredicateAtom::WellFormed(ty.into()).to_predicate(self.tcx()));
|
||||
self.prove_predicate(ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_middle::hir::map as hir_map;
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::{
|
||||
self, Binder, Predicate, PredicateAtom, ToPredicate, Ty, TyCtxt, WithConstness,
|
||||
self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt, WithConstness,
|
||||
};
|
||||
use rustc_session::CrateDisambiguator;
|
||||
use rustc_span::symbol::Symbol;
|
||||
@ -378,7 +378,7 @@ fn well_formed_types_in_env<'tcx>(
|
||||
let input_clauses = inputs.into_iter().filter_map(|arg| {
|
||||
match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => {
|
||||
let binder = Binder::dummy(PredicateAtom::TypeWellFormedFromEnv(ty));
|
||||
let binder = Binder::dummy(PredicateKind::TypeWellFormedFromEnv(ty));
|
||||
Some(tcx.mk_predicate(binder))
|
||||
}
|
||||
|
||||
|
@ -1177,9 +1177,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
obligation.predicate
|
||||
);
|
||||
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(pred, _) => {
|
||||
ty::PredicateKind::Trait(pred, _) => {
|
||||
let pred = bound_predicate.rebind(pred);
|
||||
associated_types.entry(span).or_default().extend(
|
||||
tcx.associated_items(pred.def_id())
|
||||
@ -1188,7 +1188,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
.map(|item| item.def_id),
|
||||
);
|
||||
}
|
||||
ty::PredicateAtom::Projection(pred) => {
|
||||
ty::PredicateKind::Projection(pred) => {
|
||||
let pred = bound_predicate.rebind(pred);
|
||||
// A `Self` within the original bound will be substituted with a
|
||||
// `trait_object_dummy_self`, so check for that.
|
||||
|
@ -544,9 +544,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.infcx.instantiate_opaque_types(id, self.body_id, self.param_env, ty, span);
|
||||
let mut suggest_box = !impl_trait_ret_ty.obligations.is_empty();
|
||||
for o in impl_trait_ret_ty.obligations {
|
||||
match o.predicate.bound_atom().skip_binder() {
|
||||
ty::PredicateAtom::Trait(t, constness) => {
|
||||
let pred = ty::PredicateAtom::Trait(
|
||||
match o.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(t, constness) => {
|
||||
let pred = ty::PredicateKind::Trait(
|
||||
ty::TraitPredicate {
|
||||
trait_ref: ty::TraitRef {
|
||||
def_id: t.def_id(),
|
||||
|
@ -192,9 +192,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
obligation.predicate
|
||||
);
|
||||
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
if let ty::PredicateAtom::Projection(proj_predicate) =
|
||||
obligation.predicate.skip_binders()
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
if let ty::PredicateKind::Projection(proj_predicate) =
|
||||
obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
// Given a Projection predicate, we can potentially infer
|
||||
// the complete signature.
|
||||
@ -622,8 +622,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// where R is the return type we are expecting. This type `T`
|
||||
// will be our output.
|
||||
let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| {
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
if let ty::PredicateAtom::Projection(proj_predicate) = bound_predicate.skip_binder() {
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
if let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() {
|
||||
self.deduce_future_output_from_projection(
|
||||
obligation.cause.span,
|
||||
bound_predicate.rebind(proj_predicate),
|
||||
|
@ -583,9 +583,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
while !queue.is_empty() {
|
||||
let obligation = queue.remove(0);
|
||||
debug!("coerce_unsized resolve step: {:?}", obligation);
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
let trait_pred = match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(trait_pred, _)
|
||||
ty::PredicateKind::Trait(trait_pred, _)
|
||||
if traits.contains(&trait_pred.def_id()) =>
|
||||
{
|
||||
if unsize_did == trait_pred.def_id() {
|
||||
|
@ -226,13 +226,13 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
// could be extended easily also to the other `Predicate`.
|
||||
let predicate_matches_closure = |p: Predicate<'tcx>| {
|
||||
let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env);
|
||||
let predicate = predicate.bound_atom();
|
||||
let p = p.bound_atom();
|
||||
let predicate = predicate.kind();
|
||||
let p = p.kind();
|
||||
match (predicate.skip_binder(), p.skip_binder()) {
|
||||
(ty::PredicateAtom::Trait(a, _), ty::PredicateAtom::Trait(b, _)) => {
|
||||
(ty::PredicateKind::Trait(a, _), ty::PredicateKind::Trait(b, _)) => {
|
||||
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
||||
}
|
||||
(ty::PredicateAtom::Projection(a), ty::PredicateAtom::Projection(b)) => {
|
||||
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
|
||||
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
|
||||
}
|
||||
_ => predicate == p,
|
||||
|
@ -542,7 +542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.register_predicate(traits::Obligation::new(
|
||||
cause,
|
||||
self.param_env,
|
||||
ty::PredicateAtom::WellFormed(arg).to_predicate(self.tcx),
|
||||
ty::PredicateKind::WellFormed(arg).to_predicate(self.tcx),
|
||||
));
|
||||
}
|
||||
|
||||
@ -764,21 +764,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.pending_obligations()
|
||||
.into_iter()
|
||||
.filter_map(move |obligation| {
|
||||
let bound_predicate = obligation.predicate.bound_atom();
|
||||
let bound_predicate = obligation.predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
Some((bound_predicate.rebind(data).to_poly_trait_ref(self.tcx), obligation))
|
||||
}
|
||||
ty::PredicateAtom::Trait(data, _) => {
|
||||
ty::PredicateKind::Trait(data, _) => {
|
||||
Some((bound_predicate.rebind(data).to_poly_trait_ref(), obligation))
|
||||
}
|
||||
ty::PredicateAtom::Subtype(..) => None,
|
||||
ty::PredicateAtom::RegionOutlives(..) => None,
|
||||
ty::PredicateAtom::TypeOutlives(..) => None,
|
||||
ty::PredicateAtom::WellFormed(..) => None,
|
||||
ty::PredicateAtom::ObjectSafe(..) => None,
|
||||
ty::PredicateAtom::ConstEvaluatable(..) => None,
|
||||
ty::PredicateAtom::ConstEquate(..) => None,
|
||||
ty::PredicateKind::Subtype(..) => None,
|
||||
ty::PredicateKind::RegionOutlives(..) => None,
|
||||
ty::PredicateKind::TypeOutlives(..) => None,
|
||||
ty::PredicateKind::WellFormed(..) => None,
|
||||
ty::PredicateKind::ObjectSafe(..) => None,
|
||||
ty::PredicateKind::ConstEvaluatable(..) => None,
|
||||
ty::PredicateKind::ConstEquate(..) => None,
|
||||
// N.B., this predicate is created by breaking down a
|
||||
// `ClosureType: FnFoo()` predicate, where
|
||||
// `ClosureType` represents some `Closure`. It can't
|
||||
@ -787,8 +787,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// this closure yet; this is exactly why the other
|
||||
// code is looking for a self type of a unresolved
|
||||
// inference variable.
|
||||
ty::PredicateAtom::ClosureKind(..) => None,
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateKind::ClosureKind(..) => None,
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
})
|
||||
.filter(move |(tr, _)| self.self_type_matches_expected_vid(*tr, ty_var_root))
|
||||
|
@ -923,8 +923,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let ty::PredicateAtom::Trait(predicate, _) =
|
||||
error.obligation.predicate.skip_binders()
|
||||
if let ty::PredicateKind::Trait(predicate, _) =
|
||||
error.obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
// Collect the argument position for all arguments that could have caused this
|
||||
// `FulfillmentError`.
|
||||
@ -974,8 +974,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if let hir::ExprKind::Path(qpath) = &path.kind {
|
||||
if let hir::QPath::Resolved(_, path) = &qpath {
|
||||
for error in errors {
|
||||
if let ty::PredicateAtom::Trait(predicate, _) =
|
||||
error.obligation.predicate.skip_binders()
|
||||
if let ty::PredicateKind::Trait(predicate, _) =
|
||||
error.obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
// If any of the type arguments in this path segment caused the
|
||||
// `FullfillmentError`, point at its span (#61860).
|
||||
|
@ -194,8 +194,8 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
||||
parent: None,
|
||||
predicates: tcx.arena.alloc_from_iter(
|
||||
self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(data, _) if data.self_ty().is_param(index) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(data, _) if data.self_ty().is_param(index) => {
|
||||
// HACK(eddyb) should get the original `Span`.
|
||||
let span = tcx.def_span(def_id);
|
||||
Some((predicate, span))
|
||||
|
@ -478,8 +478,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
|
||||
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
|
||||
// We don't care about regions here.
|
||||
.filter_map(|obligation| match obligation.predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => {
|
||||
.filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => {
|
||||
let span = predicates
|
||||
.predicates
|
||||
.iter()
|
||||
|
@ -399,7 +399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
obligations.push(traits::Obligation::new(
|
||||
cause,
|
||||
self.param_env,
|
||||
ty::PredicateAtom::WellFormed(method_ty.into()).to_predicate(tcx),
|
||||
ty::PredicateKind::WellFormed(method_ty.into()).to_predicate(tcx),
|
||||
));
|
||||
|
||||
let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };
|
||||
|
@ -795,9 +795,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
debug!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty);
|
||||
|
||||
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
let bound_predicate = predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(trait_predicate, _) => {
|
||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
||||
match *trait_predicate.trait_ref.self_ty().kind() {
|
||||
ty::Param(p) if p == param_ty => {
|
||||
Some(bound_predicate.rebind(trait_predicate.trait_ref))
|
||||
@ -805,16 +805,16 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::RegionOutlives(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::TypeOutlives(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::TypeOutlives(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -582,8 +582,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let mut collect_type_param_suggestions =
|
||||
|self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| {
|
||||
// We don't care about regions here, so it's fine to skip the binder here.
|
||||
if let (ty::Param(_), ty::PredicateAtom::Trait(p, _)) =
|
||||
(self_ty.kind(), parent_pred.skip_binders())
|
||||
if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) =
|
||||
(self_ty.kind(), parent_pred.kind().skip_binder())
|
||||
{
|
||||
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() {
|
||||
let node = def.did.as_local().map(|def_id| {
|
||||
@ -637,9 +637,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
let mut format_pred = |pred: ty::Predicate<'tcx>| {
|
||||
let bound_predicate = pred.bound_atom();
|
||||
let bound_predicate = pred.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Projection(pred) => {
|
||||
ty::PredicateKind::Projection(pred) => {
|
||||
let pred = bound_predicate.rebind(pred);
|
||||
// `<Foo as Iterator>::Item = String`.
|
||||
let trait_ref =
|
||||
@ -658,7 +658,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
bound_span_label(trait_ref.self_ty(), &obligation, &quiet);
|
||||
Some((obligation, trait_ref.self_ty()))
|
||||
}
|
||||
ty::PredicateAtom::Trait(poly_trait_ref, _) => {
|
||||
ty::PredicateKind::Trait(poly_trait_ref, _) => {
|
||||
let p = poly_trait_ref.trait_ref;
|
||||
let self_ty = p.self_ty();
|
||||
let path = p.print_only_trait_path();
|
||||
@ -992,11 +992,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// implementing a trait would be legal but is rejected
|
||||
// here).
|
||||
unsatisfied_predicates.iter().all(|(p, _)| {
|
||||
match p.skip_binders() {
|
||||
match p.kind().skip_binder() {
|
||||
// Hide traits if they are present in predicates as they can be fixed without
|
||||
// having to implement them.
|
||||
ty::PredicateAtom::Trait(t, _) => t.def_id() == info.def_id,
|
||||
ty::PredicateAtom::Projection(p) => {
|
||||
ty::PredicateKind::Trait(t, _) => t.def_id() == info.def_id,
|
||||
ty::PredicateKind::Projection(p) => {
|
||||
p.projection_ty.item_def_id == info.def_id
|
||||
}
|
||||
_ => false,
|
||||
|
@ -864,9 +864,9 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||
let mut projections = vec![];
|
||||
for (predicate, _) in predicates.predicates {
|
||||
debug!("predicate {:?}", predicate);
|
||||
let bound_predicate = predicate.bound_atom();
|
||||
let bound_predicate = predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(trait_predicate, _) => {
|
||||
ty::PredicateKind::Trait(trait_predicate, _) => {
|
||||
let entry = types.entry(trait_predicate.self_ty()).or_default();
|
||||
let def_id = trait_predicate.def_id();
|
||||
if Some(def_id) != tcx.lang_items().sized_trait() {
|
||||
@ -875,7 +875,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||
entry.push(trait_predicate.def_id());
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::Projection(projection_pred) => {
|
||||
ty::PredicateKind::Projection(projection_pred) => {
|
||||
projections.push(bound_predicate.rebind(projection_pred));
|
||||
}
|
||||
_ => {}
|
||||
|
@ -532,7 +532,7 @@ fn check_type_defn<'tcx, F>(
|
||||
fcx.register_predicate(traits::Obligation::new(
|
||||
cause,
|
||||
fcx.param_env,
|
||||
ty::PredicateAtom::ConstEvaluatable(
|
||||
ty::PredicateKind::ConstEvaluatable(
|
||||
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
|
||||
discr_substs,
|
||||
)
|
||||
|
@ -562,8 +562,8 @@ fn type_param_predicates(
|
||||
let extra_predicates = extend.into_iter().chain(
|
||||
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
|
||||
.into_iter()
|
||||
.filter(|(predicate, _)| match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(data, _) => data.self_ty().is_param(index),
|
||||
.filter(|(predicate, _)| match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index),
|
||||
_ => false,
|
||||
}),
|
||||
);
|
||||
@ -1027,7 +1027,7 @@ fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredi
|
||||
// which will, in turn, reach indirect supertraits.
|
||||
for &(pred, span) in superbounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::PredicateAtom::Trait(bound, _) = pred.skip_binders() {
|
||||
if let ty::PredicateKind::Trait(bound, _) = pred.kind().skip_binder() {
|
||||
tcx.at(span).super_predicates_of(bound.def_id());
|
||||
}
|
||||
}
|
||||
@ -1946,7 +1946,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||
} else {
|
||||
let span = bound_pred.bounded_ty.span;
|
||||
let re_root_empty = tcx.lifetimes.re_root_empty;
|
||||
let predicate = ty::Binder::bind(ty::PredicateAtom::TypeOutlives(
|
||||
let predicate = ty::Binder::bind(ty::PredicateKind::TypeOutlives(
|
||||
ty::OutlivesPredicate(ty, re_root_empty),
|
||||
));
|
||||
predicates.insert((predicate.to_predicate(tcx), span));
|
||||
@ -1990,7 +1990,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||
hir::GenericBound::Outlives(lifetime) => {
|
||||
let region = AstConv::ast_region_to_region(&icx, lifetime, None);
|
||||
predicates.insert((
|
||||
ty::Binder::bind(ty::PredicateAtom::TypeOutlives(
|
||||
ty::Binder::bind(ty::PredicateKind::TypeOutlives(
|
||||
ty::OutlivesPredicate(ty, region),
|
||||
))
|
||||
.to_predicate(tcx),
|
||||
@ -2010,7 +2010,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
|
||||
}
|
||||
_ => bug!(),
|
||||
};
|
||||
let pred = ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
||||
let pred = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
|
||||
.to_predicate(icx.tcx);
|
||||
|
||||
(pred, span)
|
||||
@ -2075,7 +2075,7 @@ fn const_evaluatable_predicates_of<'tcx>(
|
||||
if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val {
|
||||
let span = self.tcx.hir().span(c.hir_id);
|
||||
self.preds.insert((
|
||||
ty::PredicateAtom::ConstEvaluatable(def, substs).to_predicate(self.tcx),
|
||||
ty::PredicateKind::ConstEvaluatable(def, substs).to_predicate(self.tcx),
|
||||
span,
|
||||
));
|
||||
}
|
||||
@ -2094,7 +2094,7 @@ fn const_evaluatable_predicates_of<'tcx>(
|
||||
fn visit_const(&mut self, ct: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val {
|
||||
self.preds.insert((
|
||||
ty::PredicateAtom::ConstEvaluatable(def, substs).to_predicate(self.tcx),
|
||||
ty::PredicateKind::ConstEvaluatable(def, substs).to_predicate(self.tcx),
|
||||
self.span,
|
||||
));
|
||||
}
|
||||
@ -2180,12 +2180,12 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
|
||||
.predicates
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|(pred, _)| match pred.skip_binders() {
|
||||
ty::PredicateAtom::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()),
|
||||
ty::PredicateAtom::Projection(proj) => {
|
||||
.filter(|(pred, _)| match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()),
|
||||
ty::PredicateKind::Projection(proj) => {
|
||||
!is_assoc_item_ty(proj.projection_ty.self_ty())
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(outlives) => !is_assoc_item_ty(outlives.0),
|
||||
ty::PredicateKind::TypeOutlives(outlives) => !is_assoc_item_ty(outlives.0),
|
||||
_ => true,
|
||||
})
|
||||
.collect();
|
||||
@ -2214,7 +2214,8 @@ fn projection_ty_from_predicates(
|
||||
let (ty_def_id, item_def_id) = key;
|
||||
let mut projection_ty = None;
|
||||
for (predicate, _) in tcx.predicates_of(ty_def_id).predicates {
|
||||
if let ty::PredicateAtom::Projection(projection_predicate) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder()
|
||||
{
|
||||
if item_def_id == projection_predicate.projection_ty.item_def_id {
|
||||
projection_ty = Some(projection_predicate.projection_ty);
|
||||
break;
|
||||
@ -2261,7 +2262,7 @@ fn predicates_from_bound<'tcx>(
|
||||
}
|
||||
hir::GenericBound::Outlives(ref lifetime) => {
|
||||
let region = astconv.ast_region_to_region(lifetime, None);
|
||||
let pred = ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(param_ty, region))
|
||||
let pred = ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(param_ty, region))
|
||||
.to_predicate(astconv.tcx());
|
||||
vec![(pred, lifetime.span)]
|
||||
}
|
||||
|
@ -36,13 +36,14 @@ fn associated_type_bounds<'tcx>(
|
||||
let trait_def_id = tcx.associated_item(assoc_item_def_id).container.id();
|
||||
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id.expect_local());
|
||||
|
||||
let bounds_from_parent =
|
||||
trait_predicates.predicates.iter().copied().filter(|(pred, _)| match pred.skip_binders() {
|
||||
ty::PredicateAtom::Trait(tr, _) => tr.self_ty() == item_ty,
|
||||
ty::PredicateAtom::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
|
||||
ty::PredicateAtom::TypeOutlives(outlives) => outlives.0 == item_ty,
|
||||
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
|
||||
match pred.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(tr, _) => tr.self_ty() == item_ty,
|
||||
ty::PredicateKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
|
||||
ty::PredicateKind::TypeOutlives(outlives) => outlives.0 == item_ty,
|
||||
_ => false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let all_bounds = tcx
|
||||
.arena
|
||||
|
@ -183,7 +183,8 @@ pub fn setup_constraining_predicates<'tcx>(
|
||||
for j in i..predicates.len() {
|
||||
// Note that we don't have to care about binders here,
|
||||
// as the impl trait ref never contains any late-bound regions.
|
||||
if let ty::PredicateAtom::Projection(projection) = predicates[j].0.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(projection) = predicates[j].0.kind().skip_binder()
|
||||
{
|
||||
// Special case: watch out for some kind of sneaky attempt
|
||||
// to project out an associated type defined by this very
|
||||
// trait.
|
||||
|
@ -198,7 +198,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
|
||||
// the functions in `cgp` add the constrained parameters to a list of
|
||||
// unconstrained parameters.
|
||||
for (predicate, _) in impl_generic_predicates.predicates.iter() {
|
||||
if let ty::PredicateAtom::Projection(proj) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(proj) = predicate.kind().skip_binder() {
|
||||
let projection_ty = proj.projection_ty;
|
||||
let projected_ty = proj.ty;
|
||||
|
||||
@ -360,13 +360,13 @@ fn check_predicates<'tcx>(
|
||||
|
||||
fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>, span: Span) {
|
||||
debug!("can_specialize_on(predicate = {:?})", predicate);
|
||||
match predicate.skip_binders() {
|
||||
match predicate.kind().skip_binder() {
|
||||
// Global predicates are either always true or always false, so we
|
||||
// are fine to specialize on.
|
||||
_ if predicate.is_global() => (),
|
||||
// We allow specializing on explicitly marked traits with no associated
|
||||
// items.
|
||||
ty::PredicateAtom::Trait(pred, hir::Constness::NotConst) => {
|
||||
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
|
||||
if !matches!(
|
||||
trait_predicate_kind(tcx, predicate),
|
||||
Some(TraitSpecializationKind::Marker)
|
||||
@ -393,20 +393,20 @@ fn trait_predicate_kind<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
) -> Option<TraitSpecializationKind> {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::Trait(pred, hir::Constness::NotConst) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
|
||||
Some(tcx.trait_def(pred.def_id()).specialization_kind)
|
||||
}
|
||||
ty::PredicateAtom::Trait(_, hir::Constness::Const)
|
||||
| ty::PredicateAtom::RegionOutlives(_)
|
||||
| ty::PredicateAtom::TypeOutlives(_)
|
||||
| ty::PredicateAtom::Projection(_)
|
||||
| ty::PredicateAtom::WellFormed(_)
|
||||
| ty::PredicateAtom::Subtype(_)
|
||||
| ty::PredicateAtom::ObjectSafe(_)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None,
|
||||
ty::PredicateKind::Trait(_, hir::Constness::Const)
|
||||
| ty::PredicateKind::RegionOutlives(_)
|
||||
| ty::PredicateKind::TypeOutlives(_)
|
||||
| ty::PredicateKind::Projection(_)
|
||||
| ty::PredicateKind::WellFormed(_)
|
||||
| ty::PredicateKind::Subtype(_)
|
||||
| ty::PredicateKind::ObjectSafe(_)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
||||
|
||||
// process predicates and convert to `RequiredPredicates` entry, see below
|
||||
for &(predicate, span) in predicates.predicates {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => {
|
||||
insert_outlives_predicate(
|
||||
tcx,
|
||||
(*ty).into(),
|
||||
@ -40,7 +40,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(OutlivesPredicate(ref reg1, ref reg2)) => {
|
||||
ty::PredicateKind::RegionOutlives(OutlivesPredicate(ref reg1, ref reg2)) => {
|
||||
insert_outlives_predicate(
|
||||
tcx,
|
||||
(*reg1).into(),
|
||||
@ -50,15 +50,15 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => (),
|
||||
ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
|
||||
if tcx.has_attr(item_def_id, sym::rustc_outlives) {
|
||||
let mut pred: Vec<String> = predicates
|
||||
.iter()
|
||||
.map(|(out_pred, _)| match out_pred.bound_atom().skip_binder() {
|
||||
ty::PredicateAtom::RegionOutlives(p) => p.to_string(),
|
||||
ty::PredicateAtom::TypeOutlives(p) => p.to_string(),
|
||||
.map(|(out_pred, _)| match out_pred.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(p) => p.to_string(),
|
||||
ty::PredicateKind::TypeOutlives(p) => p.to_string(),
|
||||
err => bug!("unexpected predicate {:?}", err),
|
||||
})
|
||||
.collect();
|
||||
@ -85,12 +85,12 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
|
||||
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
||||
match kind1.unpack() {
|
||||
GenericArgKind::Type(ty1) => Some((
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
|
||||
.to_predicate(tcx),
|
||||
span,
|
||||
)),
|
||||
GenericArgKind::Lifetime(region1) => Some((
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
|
||||
region1, region2,
|
||||
))
|
||||
.to_predicate(tcx),
|
||||
|
@ -313,12 +313,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
pred: ty::Predicate<'tcx>,
|
||||
) -> FxHashSet<GenericParamDef> {
|
||||
let bound_predicate = pred.bound_atom();
|
||||
let bound_predicate = pred.kind();
|
||||
let regions = match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(poly_trait_pred, _) => {
|
||||
ty::PredicateKind::Trait(poly_trait_pred, _) => {
|
||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_trait_pred))
|
||||
}
|
||||
ty::PredicateAtom::Projection(poly_proj_pred) => {
|
||||
ty::PredicateKind::Projection(poly_proj_pred) => {
|
||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_proj_pred))
|
||||
}
|
||||
_ => return FxHashSet::default(),
|
||||
@ -463,8 +463,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
.iter()
|
||||
.filter(|p| {
|
||||
!orig_bounds.contains(p)
|
||||
|| match p.skip_binders() {
|
||||
ty::PredicateAtom::Trait(pred, _) => pred.def_id() == sized_trait,
|
||||
|| match p.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(pred, _) => pred.def_id() == sized_trait,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
|
@ -465,20 +465,20 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
|
||||
|
||||
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
|
||||
let bound_predicate = self.bound_atom();
|
||||
let bound_predicate = self.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)),
|
||||
ty::PredicateAtom::RegionOutlives(pred) => pred.clean(cx),
|
||||
ty::PredicateAtom::TypeOutlives(pred) => pred.clean(cx),
|
||||
ty::PredicateAtom::Projection(pred) => Some(pred.clean(cx)),
|
||||
ty::PredicateKind::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)),
|
||||
ty::PredicateKind::RegionOutlives(pred) => pred.clean(cx),
|
||||
ty::PredicateKind::TypeOutlives(pred) => pred.clean(cx),
|
||||
ty::PredicateKind::Projection(pred) => Some(pred.clean(cx)),
|
||||
|
||||
ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => panic!("not user writable"),
|
||||
ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => panic!("not user writable"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -743,19 +743,19 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
|
||||
.flat_map(|(p, _)| {
|
||||
let mut projection = None;
|
||||
let param_idx = (|| {
|
||||
let bound_p = p.bound_atom();
|
||||
let bound_p = p.kind();
|
||||
match bound_p.skip_binder() {
|
||||
ty::PredicateAtom::Trait(pred, _constness) => {
|
||||
ty::PredicateKind::Trait(pred, _constness) => {
|
||||
if let ty::Param(param) = pred.self_ty().kind() {
|
||||
return Some(param.index);
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
|
||||
if let ty::Param(param) = ty.kind() {
|
||||
return Some(param.index);
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::Projection(p) => {
|
||||
ty::PredicateKind::Projection(p) => {
|
||||
if let ty::Param(param) = p.projection_ty.self_ty().kind() {
|
||||
projection = Some(bound_p.rebind(p));
|
||||
return Some(param.index);
|
||||
@ -1686,12 +1686,12 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
.filter_map(|bound| {
|
||||
// Note: The substs of opaque types can contain unbound variables,
|
||||
// meaning that we have to use `ignore_quantifiers_with_unbound_vars` here.
|
||||
let bound_predicate = bound.bound_atom();
|
||||
let bound_predicate = bound.kind();
|
||||
let trait_ref = match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(tr, _constness) => {
|
||||
ty::PredicateKind::Trait(tr, _constness) => {
|
||||
bound_predicate.rebind(tr.trait_ref)
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
|
||||
if let Some(r) = reg.clean(cx) {
|
||||
regions.push(GenericBound::Outlives(r));
|
||||
}
|
||||
@ -1710,8 +1710,8 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
let bounds: Vec<_> = bounds
|
||||
.iter()
|
||||
.filter_map(|bound| {
|
||||
if let ty::PredicateAtom::Projection(proj) =
|
||||
bound.bound_atom().skip_binder()
|
||||
if let ty::PredicateKind::Projection(proj) =
|
||||
bound.kind().skip_binder()
|
||||
{
|
||||
if proj.projection_ty.trait_ref(cx.tcx)
|
||||
== trait_ref.skip_binder()
|
||||
|
@ -129,7 +129,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
|
||||
.predicates
|
||||
.iter()
|
||||
.filter_map(|(pred, _)| {
|
||||
if let ty::PredicateAtom::Trait(pred, _) = pred.skip_binders() {
|
||||
if let ty::PredicateKind::Trait(pred, _) = pred.kind().skip_binder() {
|
||||
if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
|
||||
} else {
|
||||
None
|
||||
|
@ -4,7 +4,7 @@ use rustc_hir::{Body, FnDecl, HirId};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::{Opaque, PredicateAtom::Trait};
|
||||
use rustc_middle::ty::{Opaque, PredicateKind::Trait};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
|
||||
@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||
&obligation,
|
||||
);
|
||||
if let Trait(trait_pred, _) =
|
||||
obligation.predicate.skip_binders()
|
||||
obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
db.note(&format!(
|
||||
"`{}` doesn't implement `{}`",
|
||||
|
@ -1697,7 +1697,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
if let ty::Opaque(def_id, _) = *ret_ty.kind() {
|
||||
// one of the associated types must be Self
|
||||
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) {
|
||||
if let ty::PredicateAtom::Projection(projection_predicate) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
|
||||
// walk the associated type and check for Self
|
||||
if contains_ty(projection_predicate.ty, self_ty) {
|
||||
return;
|
||||
|
@ -115,13 +115,10 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||
.filter(|p| !p.is_global())
|
||||
.filter_map(|obligation| {
|
||||
// Note that we do not want to deal with qualified predicates here.
|
||||
match obligation.predicate.bound_atom().skip_binder() {
|
||||
ty::PredicateAtom::Trait(pred, _) if !pred.has_escaping_bound_vars() => {
|
||||
if pred.def_id() == sized_trait {
|
||||
return None;
|
||||
}
|
||||
match obligation.predicate.kind().no_bound_vars() {
|
||||
Some(ty::PredicateKind::Trait(pred, _)) if pred.def_id() != sized_trait => {
|
||||
Some(pred)
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{Expr, ExprKind, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::{GenericPredicates, PredicateAtom, ProjectionPredicate, TraitPredicate};
|
||||
use rustc_middle::ty::{GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
@ -42,7 +42,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
|
||||
let mut preds = Vec::new();
|
||||
for (pred, _) in generics.predicates {
|
||||
if_chain! {
|
||||
if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders();
|
||||
if let PredicateKind::Trait(poly_trait_pred, _) = pred.kind().skip_binder();
|
||||
let trait_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(poly_trait_pred));
|
||||
if let Some(trait_def_id) = trait_id;
|
||||
if trait_def_id == trait_pred.trait_ref.def_id;
|
||||
@ -60,7 +60,7 @@ fn get_projection_pred<'tcx>(
|
||||
pred: TraitPredicate<'tcx>,
|
||||
) -> Option<ProjectionPredicate<'tcx>> {
|
||||
generics.predicates.iter().find_map(|(proj_pred, _)| {
|
||||
if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() {
|
||||
if let ty::PredicateKind::Projection(proj_pred) = proj_pred.kind().skip_binder() {
|
||||
let projection_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(proj_pred));
|
||||
if projection_pred.projection_ty.substs == pred.trait_ref.substs {
|
||||
return Some(projection_pred);
|
||||
|
@ -1470,7 +1470,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
|
||||
ty::Opaque(ref def_id, _) => {
|
||||
for (predicate, _) in cx.tcx.explicit_item_bounds(*def_id) {
|
||||
if let ty::PredicateAtom::Trait(trait_predicate, _) = predicate.skip_binders() {
|
||||
if let ty::PredicateKind::Trait(trait_predicate, _) = predicate.kind().skip_binder() {
|
||||
if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
|
||||
return true;
|
||||
}
|
||||
|
@ -19,18 +19,18 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>) -> McfResult {
|
||||
loop {
|
||||
let predicates = tcx.predicates_of(current);
|
||||
for (predicate, _) in predicates.predicates {
|
||||
match predicate.skip_binders() {
|
||||
ty::PredicateAtom::RegionOutlives(_)
|
||||
| ty::PredicateAtom::TypeOutlives(_)
|
||||
| ty::PredicateAtom::WellFormed(_)
|
||||
| ty::PredicateAtom::Projection(_)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateAtom::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
||||
ty::PredicateAtom::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
||||
ty::PredicateAtom::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
|
||||
ty::PredicateAtom::Trait(pred, _) => {
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(_)
|
||||
| ty::PredicateKind::TypeOutlives(_)
|
||||
| ty::PredicateKind::WellFormed(_)
|
||||
| ty::PredicateKind::Projection(_)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::Trait(pred, _) => {
|
||||
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user