Review changes

This commit is contained in:
Jack Huey 2021-01-07 11:20:28 -05:00
parent 66c179946b
commit 3dea68de1d
67 changed files with 581 additions and 590 deletions

View file

@ -530,10 +530,10 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
let atom = match k1.unpack() { let atom = match k1.unpack() {
GenericArgKind::Lifetime(r1) => { GenericArgKind::Lifetime(r1) => {
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2)) ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
} }
GenericArgKind::Type(t1) => { GenericArgKind::Type(t1) => {
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(t1, r2)) ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t1, r2))
} }
GenericArgKind::Const(..) => { GenericArgKind::Const(..) => {
// Consts cannot outlive one another, so we don't expect to // 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 { self.obligations.push(Obligation {
cause: self.cause.clone(), cause: self.cause.clone(),
param_env: self.param_env, 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), .to_predicate(self.infcx.tcx),
recursion_depth: 0, recursion_depth: 0,
}); });

View file

@ -358,7 +358,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.obligations.push(Obligation::new( self.obligations.push(Obligation::new(
self.trace.cause.clone(), self.trace.cause.clone(),
self.param_env, self.param_env,
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>, b: &'tcx ty::Const<'tcx>,
) { ) {
let predicate = if a_is_expected { let predicate = if a_is_expected {
ty::PredicateAtom::ConstEquate(a, b) ty::PredicateKind::ConstEquate(a, b)
} else { } else {
ty::PredicateAtom::ConstEquate(b, a) ty::PredicateKind::ConstEquate(b, a)
}; };
self.obligations.push(Obligation::new( self.obligations.push(Obligation::new(
self.trace.cause.clone(), self.trace.cause.clone(),

View file

@ -1706,8 +1706,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
for (predicate, _) in bounds { for (predicate, _) in bounds {
let predicate = predicate.subst(self.tcx, substs); let predicate = predicate.subst(self.tcx, substs);
if let ty::PredicateAtom::Projection(projection_predicate) = if let ty::PredicateKind::Projection(projection_predicate) =
predicate.skip_binders() predicate.kind().skip_binder()
{ {
if projection_predicate.projection_ty.item_def_id == item_def_id { if projection_predicate.projection_ty.item_def_id == item_def_id {
// We don't account for multiple `Future::Output = Ty` contraints. // We don't account for multiple `Future::Output = Ty` contraints.

View file

@ -15,20 +15,21 @@ pub fn explicit_outlives_bounds<'tcx>(
param_env param_env
.caller_bounds() .caller_bounds()
.into_iter() .into_iter()
.map(ty::Predicate::skip_binders) .map(ty::Predicate::kind)
.map(ty::Binder::skip_binder)
.filter(|atom| !atom.has_escaping_bound_vars()) .filter(|atom| !atom.has_escaping_bound_vars())
.filter_map(move |atom| match atom { .filter_map(move |atom| match atom {
ty::PredicateAtom::Projection(..) ty::PredicateKind::Projection(..)
| ty::PredicateAtom::Trait(..) | ty::PredicateKind::Trait(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::TypeOutlives(..) | ty::PredicateKind::TypeOutlives(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None, | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => { ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
Some(OutlivesBound::RegionSubRegion(r_b, r_a)) Some(OutlivesBound::RegionSubRegion(r_b, r_a))
} }
}) })

View file

@ -100,7 +100,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
self.fields.obligations.push(Obligation::new( self.fields.obligations.push(Obligation::new(
self.fields.trace.cause.clone(), self.fields.trace.cause.clone(),
self.fields.param_env, self.fields.param_env,
ty::PredicateAtom::Subtype(ty::SubtypePredicate { ty::PredicateKind::Subtype(ty::SubtypePredicate {
a_is_expected: self.a_is_expected, a_is_expected: self.a_is_expected,
a, a,
b, b,

View file

@ -9,7 +9,7 @@ pub fn anonymize_predicate<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
pred: ty::Predicate<'tcx>, pred: ty::Predicate<'tcx>,
) -> 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) tcx.reuse_or_mk_predicate(pred, new)
} }
@ -121,9 +121,9 @@ impl Elaborator<'tcx> {
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) { fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
let tcx = self.visited.tcx; let tcx = self.visited.tcx;
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(data, _) => { ty::PredicateKind::Trait(data, _) => {
// Get predicates declared on the trait. // Get predicates declared on the trait.
let predicates = tcx.super_predicates_of(data.def_id()); let predicates = tcx.super_predicates_of(data.def_id());
@ -145,36 +145,36 @@ impl Elaborator<'tcx> {
self.stack.extend(obligations); self.stack.extend(obligations);
} }
ty::PredicateAtom::WellFormed(..) => { ty::PredicateKind::WellFormed(..) => {
// Currently, we do not elaborate WF predicates, // Currently, we do not elaborate WF predicates,
// although we easily could. // although we easily could.
} }
ty::PredicateAtom::ObjectSafe(..) => { ty::PredicateKind::ObjectSafe(..) => {
// Currently, we do not elaborate object-safe // Currently, we do not elaborate object-safe
// predicates. // predicates.
} }
ty::PredicateAtom::Subtype(..) => { ty::PredicateKind::Subtype(..) => {
// Currently, we do not "elaborate" predicates like `X <: Y`, // Currently, we do not "elaborate" predicates like `X <: Y`,
// though conceivably we might. // though conceivably we might.
} }
ty::PredicateAtom::Projection(..) => { ty::PredicateKind::Projection(..) => {
// Nothing to elaborate in a projection predicate. // 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. // 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 // Currently, we do not elaborate const-evaluatable
// predicates. // predicates.
} }
ty::PredicateAtom::ConstEquate(..) => { ty::PredicateKind::ConstEquate(..) => {
// Currently, we do not elaborate const-equate // Currently, we do not elaborate const-equate
// predicates. // predicates.
} }
ty::PredicateAtom::RegionOutlives(..) => { ty::PredicateKind::RegionOutlives(..) => {
// Nothing to elaborate from `'a: 'b`. // 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 // We know that `T: 'a` for some type `T`. We can
// often elaborate this. For example, if we know that // often elaborate this. For example, if we know that
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if // `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@ -204,7 +204,7 @@ impl Elaborator<'tcx> {
if r.is_late_bound() { if r.is_late_bound() {
None None
} else { } else {
Some(ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate( Some(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
r, r_min, r, r_min,
))) )))
} }
@ -212,7 +212,7 @@ impl Elaborator<'tcx> {
Component::Param(p) => { Component::Param(p) => {
let ty = tcx.mk_ty_param(p.index, p.name); 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, ty, r_min,
))) )))
} }
@ -237,7 +237,7 @@ impl Elaborator<'tcx> {
}), }),
); );
} }
ty::PredicateAtom::TypeWellFormedFromEnv(..) => { ty::PredicateKind::TypeWellFormedFromEnv(..) => {
// Nothing to elaborate // Nothing to elaborate
} }
} }

View file

@ -1550,13 +1550,13 @@ declare_lint_pass!(
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::PredicateAtom::*; use rustc_middle::ty::PredicateKind::*;
if cx.tcx.features().trivial_bounds { if cx.tcx.features().trivial_bounds {
let def_id = cx.tcx.hir().local_def_id(item.hir_id); let def_id = cx.tcx.hir().local_def_id(item.hir_id);
let predicates = cx.tcx.predicates_of(def_id); let predicates = cx.tcx.predicates_of(def_id);
for &(predicate, span) in predicates.predicates { 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", Trait(..) => "Trait",
TypeOutlives(..) | TypeOutlives(..) |
RegionOutlives(..) => "Lifetime", RegionOutlives(..) => "Lifetime",
@ -1936,8 +1936,8 @@ impl ExplicitOutlivesRequirements {
) -> Vec<ty::Region<'tcx>> { ) -> Vec<ty::Region<'tcx>> {
inferred_outlives inferred_outlives
.iter() .iter()
.filter_map(|(pred, _)| match pred.skip_binders() { .filter_map(|(pred, _)| match pred.kind().skip_binder() {
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a { ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
ty::ReEarlyBound(ebr) if ebr.index == index => Some(b), ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
_ => None, _ => None,
}, },
@ -1952,8 +1952,8 @@ impl ExplicitOutlivesRequirements {
) -> Vec<ty::Region<'tcx>> { ) -> Vec<ty::Region<'tcx>> {
inferred_outlives inferred_outlives
.iter() .iter()
.filter_map(|(pred, _)| match pred.skip_binders() { .filter_map(|(pred, _)| match pred.kind().skip_binder() {
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(a, b)) => { ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
a.is_param(index).then_some(b) a.is_param(index).then_some(b)
} }
_ => None, _ => None,

View file

@ -45,12 +45,12 @@ declare_lint_pass!(
impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { 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 def_id = cx.tcx.hir().local_def_id(item.hir_id);
let predicates = cx.tcx.explicit_predicates_of(def_id); let predicates = cx.tcx.explicit_predicates_of(def_id);
for &(predicate, span) in predicates.predicates { 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, Trait(trait_predicate, _constness) => trait_predicate,
_ => continue, _ => continue,
}; };

View file

@ -202,8 +202,8 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
let mut has_emitted = false; let mut has_emitted = false;
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) { for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
// We only look at the `DefId`, so it is safe to skip the binder here. // We only look at the `DefId`, so it is safe to skip the binder here.
if let ty::PredicateAtom::Trait(ref poly_trait_predicate, _) = if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) =
predicate.skip_binders() predicate.kind().skip_binder()
{ {
let def_id = poly_trait_predicate.trait_ref.def_id; let def_id = poly_trait_predicate.trait_ref.def_id;
let descr_pre = let descr_pre =

View file

@ -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> { 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 { 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); assert!(pos >= SHORTHAND_OFFSET);
let shorthand = 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 { } else {
ty::Binder::<ty::PredicateAtom<'tcx>>::decode(decoder) ty::Binder::<ty::PredicateKind<'tcx>>::decode(decoder)
}?; }?;
let predicate = decoder.tcx().mk_predicate(predicate_kind); let predicate = decoder.tcx().mk_predicate(predicate_kind);
Ok(predicate) Ok(predicate)

View file

@ -19,7 +19,7 @@ use crate::ty::TyKind::*;
use crate::ty::{ use crate::ty::{
self, AdtDef, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid, self, AdtDef, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid,
DefIdTree, ExistentialPredicate, FloatVar, FloatVid, GenericParamDefKind, InferConst, InferTy, 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, ProjectionTy, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyS, TyVar,
TyVid, TypeAndMut, Visibility, TyVid, TypeAndMut, Visibility,
}; };
@ -133,7 +133,7 @@ impl<'tcx> CtxtInterners<'tcx> {
} }
#[inline(never)] #[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 self.predicate
.intern(binder, |binder| { .intern(binder, |binder| {
let flags = super::flags::FlagComputation::for_predicate(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>> { impl<'tcx> Borrow<Binder<PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
fn borrow<'a>(&'a self) -> &'a Binder<PredicateAtom<'tcx>> { fn borrow<'a>(&'a self) -> &'a Binder<PredicateKind<'tcx>> {
&self.0.binder &self.0.binder
} }
} }
@ -2085,7 +2085,7 @@ impl<'tcx> TyCtxt<'tcx> {
} }
#[inline] #[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); let inner = self.interners.intern_predicate(binder);
Predicate { inner } Predicate { inner }
} }
@ -2094,9 +2094,9 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn reuse_or_mk_predicate( pub fn reuse_or_mk_predicate(
self, self,
pred: Predicate<'tcx>, pred: Predicate<'tcx>,
binder: Binder<PredicateAtom<'tcx>>, binder: Binder<PredicateKind<'tcx>>,
) -> Predicate<'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> { pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {

View file

@ -22,7 +22,7 @@ impl FlagComputation {
result 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(); let mut result = FlagComputation::new();
result.add_predicate(binder); result.add_predicate(binder);
result 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)); 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 { match atom {
ty::PredicateAtom::Trait(trait_pred, _constness) => { ty::PredicateKind::Trait(trait_pred, _constness) => {
self.add_substs(trait_pred.trait_ref.substs); 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(a);
self.add_region(b); self.add_region(b);
} }
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, region)) => { ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, region)) => {
self.add_ty(ty); self.add_ty(ty);
self.add_region(region); 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(a);
self.add_ty(b); 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_projection_ty(projection_ty);
self.add_ty(ty); self.add_ty(ty);
} }
ty::PredicateAtom::WellFormed(arg) => { ty::PredicateKind::WellFormed(arg) => {
self.add_substs(slice::from_ref(&arg)); self.add_substs(slice::from_ref(&arg));
} }
ty::PredicateAtom::ObjectSafe(_def_id) => {} ty::PredicateKind::ObjectSafe(_def_id) => {}
ty::PredicateAtom::ClosureKind(_def_id, substs, _kind) => { ty::PredicateKind::ClosureKind(_def_id, substs, _kind) => {
self.add_substs(substs); self.add_substs(substs);
} }
ty::PredicateAtom::ConstEvaluatable(_def_id, substs) => { ty::PredicateKind::ConstEvaluatable(_def_id, substs) => {
self.add_substs(substs); self.add_substs(substs);
} }
ty::PredicateAtom::ConstEquate(expected, found) => { ty::PredicateKind::ConstEquate(expected, found) => {
self.add_const(expected); self.add_const(expected);
self.add_const(found); self.add_const(found);
} }
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => { ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
self.add_ty(ty); self.add_ty(ty);
} }
} }

View file

@ -1030,7 +1030,7 @@ impl<'tcx> GenericPredicates<'tcx> {
#[derive(Debug)] #[derive(Debug)]
crate struct PredicateInner<'tcx> { crate struct PredicateInner<'tcx> {
binder: Binder<PredicateAtom<'tcx>>, binder: Binder<PredicateKind<'tcx>>,
flags: TypeFlags, flags: TypeFlags,
/// See the comment for the corresponding field of [TyS]. /// See the comment for the corresponding field of [TyS].
outer_exclusive_binder: ty::DebruijnIndex, outer_exclusive_binder: ty::DebruijnIndex,
@ -1060,23 +1060,13 @@ impl Hash for Predicate<'_> {
impl<'tcx> Eq for Predicate<'tcx> {} impl<'tcx> Eq for Predicate<'tcx> {}
impl<'tcx> Predicate<'tcx> { impl<'tcx> Predicate<'tcx> {
/// Returns the inner `PredicateAtom`. /// Converts this to a `Binder<PredicateKind<'tcx>>`. If the value was an
///
/// 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
/// `Atom`, then it is not allowed to contain escaping bound vars. /// `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 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 &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(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable)] #[derive(HashStable, TypeFoldable)]
pub enum PredicateAtom<'tcx> { pub enum PredicateKind<'tcx> {
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
/// the `Self` type of the trait reference and `A`, `B`, and `C` /// the `Self` type of the trait reference and `A`, `B`, and `C`
/// would be the type parameters. /// would be the type parameters.
@ -1229,7 +1219,7 @@ impl<'tcx> Predicate<'tcx> {
// from the substitution and the value being substituted into, and // from the substitution and the value being substituted into, and
// this trick achieves that). // this trick achieves that).
let substs = trait_ref.skip_binder().substs; let substs = trait_ref.skip_binder().substs;
let pred = self.skip_binders(); let pred = self.kind().skip_binder();
let new = pred.subst(tcx, substs); let new = pred.subst(tcx, substs);
if new != pred { ty::Binder::bind(new).to_predicate(tcx) } else { self } 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>; 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)] #[inline(always)]
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> { fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
tcx.mk_predicate(self) tcx.mk_predicate(self)
} }
} }
impl ToPredicate<'tcx> for PredicateAtom<'tcx> { impl ToPredicate<'tcx> for PredicateKind<'tcx> {
#[inline(always)] #[inline(always)]
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> { fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
debug_assert!(!self.has_escaping_bound_vars(), "escaping bound vars for {:?}", self); 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>> { impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'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) .to_predicate(tcx)
} }
} }
@ -1386,62 +1376,62 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitPredicate<'tcx>> { impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitPredicate<'tcx>> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'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> { impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'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> { impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'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> { impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'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> { impl<'tcx> Predicate<'tcx> {
pub fn to_opt_poly_trait_ref(self) -> Option<ConstnessAnd<PolyTraitRef<'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() { match predicate.skip_binder() {
PredicateAtom::Trait(t, constness) => { PredicateKind::Trait(t, constness) => {
Some(ConstnessAnd { constness, value: predicate.rebind(t.trait_ref) }) Some(ConstnessAnd { constness, value: predicate.rebind(t.trait_ref) })
} }
PredicateAtom::Projection(..) PredicateKind::Projection(..)
| PredicateAtom::Subtype(..) | PredicateKind::Subtype(..)
| PredicateAtom::RegionOutlives(..) | PredicateKind::RegionOutlives(..)
| PredicateAtom::WellFormed(..) | PredicateKind::WellFormed(..)
| PredicateAtom::ObjectSafe(..) | PredicateKind::ObjectSafe(..)
| PredicateAtom::ClosureKind(..) | PredicateKind::ClosureKind(..)
| PredicateAtom::TypeOutlives(..) | PredicateKind::TypeOutlives(..)
| PredicateAtom::ConstEvaluatable(..) | PredicateKind::ConstEvaluatable(..)
| PredicateAtom::ConstEquate(..) | PredicateKind::ConstEquate(..)
| PredicateAtom::TypeWellFormedFromEnv(..) => None, | PredicateKind::TypeWellFormedFromEnv(..) => None,
} }
} }
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> { pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
let predicate = self.bound_atom(); let predicate = self.kind();
match predicate.skip_binder() { match predicate.skip_binder() {
PredicateAtom::TypeOutlives(data) => Some(predicate.rebind(data)), PredicateKind::TypeOutlives(data) => Some(predicate.rebind(data)),
PredicateAtom::Trait(..) PredicateKind::Trait(..)
| PredicateAtom::Projection(..) | PredicateKind::Projection(..)
| PredicateAtom::Subtype(..) | PredicateKind::Subtype(..)
| PredicateAtom::RegionOutlives(..) | PredicateKind::RegionOutlives(..)
| PredicateAtom::WellFormed(..) | PredicateKind::WellFormed(..)
| PredicateAtom::ObjectSafe(..) | PredicateKind::ObjectSafe(..)
| PredicateAtom::ClosureKind(..) | PredicateKind::ClosureKind(..)
| PredicateAtom::ConstEvaluatable(..) | PredicateKind::ConstEvaluatable(..)
| PredicateAtom::ConstEquate(..) | PredicateKind::ConstEquate(..)
| PredicateAtom::TypeWellFormedFromEnv(..) => None, | PredicateKind::TypeWellFormedFromEnv(..) => None,
} }
} }
} }

View file

@ -627,8 +627,8 @@ pub trait PrettyPrinter<'tcx>:
// may contain unbound variables. We therefore do this manually. // may contain unbound variables. We therefore do this manually.
// //
// FIXME(lcnr): Find out why exactly this is the case :) // FIXME(lcnr): Find out why exactly this is the case :)
let bound_predicate = predicate.bound_atom(); let bound_predicate = predicate.kind();
if let ty::PredicateAtom::Trait(pred, _) = bound_predicate.skip_binder() { if let ty::PredicateKind::Trait(pred, _) = bound_predicate.skip_binder() {
let trait_ref = bound_predicate.rebind(pred.trait_ref); let trait_ref = bound_predicate.rebind(pred.trait_ref);
// Don't print +Sized, but rather +?Sized if absent. // Don't print +Sized, but rather +?Sized if absent.
if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() { if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() {
@ -2068,38 +2068,38 @@ define_print_and_forward_display! {
} }
ty::Predicate<'tcx> { ty::Predicate<'tcx> {
let binder = self.bound_atom(); let binder = self.kind();
p!(print(binder)) p!(print(binder))
} }
ty::PredicateAtom<'tcx> { ty::PredicateKind<'tcx> {
match *self { match *self {
ty::PredicateAtom::Trait(ref data, constness) => { ty::PredicateKind::Trait(ref data, constness) => {
if let hir::Constness::Const = constness { if let hir::Constness::Const = constness {
p!("const "); p!("const ");
} }
p!(print(data)) p!(print(data))
} }
ty::PredicateAtom::Subtype(predicate) => p!(print(predicate)), ty::PredicateKind::Subtype(predicate) => p!(print(predicate)),
ty::PredicateAtom::RegionOutlives(predicate) => p!(print(predicate)), ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)),
ty::PredicateAtom::TypeOutlives(predicate) => p!(print(predicate)), ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)),
ty::PredicateAtom::Projection(predicate) => p!(print(predicate)), ty::PredicateKind::Projection(predicate) => p!(print(predicate)),
ty::PredicateAtom::WellFormed(arg) => p!(print(arg), " well-formed"), ty::PredicateKind::WellFormed(arg) => p!(print(arg), " well-formed"),
ty::PredicateAtom::ObjectSafe(trait_def_id) => { ty::PredicateKind::ObjectSafe(trait_def_id) => {
p!("the trait `", print_def_path(trait_def_id, &[]), "` is object-safe") 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 `", p!("the closure `",
print_value_path(closure_def_id, &[]), print_value_path(closure_def_id, &[]),
write("` implements the trait `{}`", kind)) 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") 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), "`") 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") p!("the type `", print(ty), "` is found in the environment")
} }
} }

View file

@ -224,35 +224,35 @@ impl fmt::Debug for ty::ProjectionPredicate<'tcx> {
impl fmt::Debug for ty::Predicate<'tcx> { impl fmt::Debug for ty::Predicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 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 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self { match *self {
ty::PredicateAtom::Trait(ref a, constness) => { ty::PredicateKind::Trait(ref a, constness) => {
if let hir::Constness::Const = constness { if let hir::Constness::Const = constness {
write!(f, "const ")?; write!(f, "const ")?;
} }
a.fmt(f) a.fmt(f)
} }
ty::PredicateAtom::Subtype(ref pair) => pair.fmt(f), ty::PredicateKind::Subtype(ref pair) => pair.fmt(f),
ty::PredicateAtom::RegionOutlives(ref pair) => pair.fmt(f), ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
ty::PredicateAtom::TypeOutlives(ref pair) => pair.fmt(f), ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
ty::PredicateAtom::Projection(ref pair) => pair.fmt(f), ty::PredicateKind::Projection(ref pair) => pair.fmt(f),
ty::PredicateAtom::WellFormed(data) => write!(f, "WellFormed({:?})", data), ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
ty::PredicateAtom::ObjectSafe(trait_def_id) => { ty::PredicateKind::ObjectSafe(trait_def_id) => {
write!(f, "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) 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) write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)
} }
ty::PredicateAtom::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2), ty::PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => { ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
write!(f, "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> { impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
type Lifted = ty::PredicateAtom<'tcx>; type Lifted = ty::PredicateKind<'tcx>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
match self { match self {
ty::PredicateAtom::Trait(data, constness) => { ty::PredicateKind::Trait(data, constness) => {
tcx.lift(data).map(|data| ty::PredicateAtom::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::PredicateKind::Subtype(data) => tcx.lift(data).map(ty::PredicateKind::Subtype),
ty::PredicateAtom::RegionOutlives(data) => { ty::PredicateKind::RegionOutlives(data) => {
tcx.lift(data).map(ty::PredicateAtom::RegionOutlives) tcx.lift(data).map(ty::PredicateKind::RegionOutlives)
} }
ty::PredicateAtom::TypeOutlives(data) => { ty::PredicateKind::TypeOutlives(data) => {
tcx.lift(data).map(ty::PredicateAtom::TypeOutlives) tcx.lift(data).map(ty::PredicateKind::TypeOutlives)
} }
ty::PredicateAtom::Projection(data) => { ty::PredicateKind::Projection(data) => {
tcx.lift(data).map(ty::PredicateAtom::Projection) tcx.lift(data).map(ty::PredicateKind::Projection)
} }
ty::PredicateAtom::WellFormed(ty) => tcx.lift(ty).map(ty::PredicateAtom::WellFormed), ty::PredicateKind::WellFormed(ty) => tcx.lift(ty).map(ty::PredicateKind::WellFormed),
ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => { ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
tcx.lift(closure_substs).map(|closure_substs| { 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) => { ty::PredicateKind::ObjectSafe(trait_def_id) => {
Some(ty::PredicateAtom::ObjectSafe(trait_def_id)) Some(ty::PredicateKind::ObjectSafe(trait_def_id))
} }
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => { ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
tcx.lift(substs).map(|substs| ty::PredicateAtom::ConstEvaluatable(def_id, substs)) tcx.lift(substs).map(|substs| ty::PredicateKind::ConstEvaluatable(def_id, substs))
} }
ty::PredicateAtom::ConstEquate(c1, c2) => { ty::PredicateKind::ConstEquate(c1, c2) => {
tcx.lift((c1, c2)).map(|(c1, c2)| ty::PredicateAtom::ConstEquate(c1, c2)) tcx.lift((c1, c2)).map(|(c1, c2)| ty::PredicateKind::ConstEquate(c1, c2))
} }
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => { ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
tcx.lift(ty).map(ty::PredicateAtom::TypeWellFormedFromEnv) tcx.lift(ty).map(ty::PredicateKind::TypeWellFormedFromEnv)
} }
} }
} }

View file

@ -590,8 +590,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let mut found = false; let mut found = false;
for (bound, _) in bounds { for (bound, _) in bounds {
if let ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(_, r)) = if let ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_, r)) =
bound.skip_binders() bound.kind().skip_binder()
{ {
let r = r.subst(self.infcx.tcx, substs); let r = r.subst(self.infcx.tcx, substs);
if let ty::RegionKind::ReStatic = r { if let ty::RegionKind::ReStatic = r {

View file

@ -1014,7 +1014,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
} }
self.prove_predicate( 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), Locations::All(span),
ConstraintCategory::TypeAnnotation, ConstraintCategory::TypeAnnotation,
); );
@ -1266,7 +1266,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
obligations.obligations.push(traits::Obligation::new( obligations.obligations.push(traits::Obligation::new(
ObligationCause::dummy(), ObligationCause::dummy(),
param_env, param_env,
ty::PredicateAtom::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx), ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
)); ));
obligations.add( obligations.add(
infcx infcx
@ -1611,7 +1611,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.check_call_dest(body, term, &sig, destination, term_location); self.check_call_dest(body, term, &sig, destination, term_location);
self.prove_predicates( self.prove_predicates(
sig.inputs_and_output.iter().map(|ty| ty::PredicateAtom::WellFormed(ty.into())), sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())),
term_location.to_locations(), term_location.to_locations(),
ConstraintCategory::Boring, ConstraintCategory::Boring,
); );
@ -2694,7 +2694,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory, category: ConstraintCategory,
) { ) {
self.prove_predicates( self.prove_predicates(
Some(ty::PredicateAtom::Trait( Some(ty::PredicateKind::Trait(
ty::TraitPredicate { trait_ref }, ty::TraitPredicate { trait_ref },
hir::Constness::NotConst, hir::Constness::NotConst,
)), )),

View file

@ -411,24 +411,24 @@ impl Validator<'mir, 'tcx> {
loop { loop {
let predicates = tcx.predicates_of(current); let predicates = tcx.predicates_of(current);
for (predicate, _) in predicates.predicates { for (predicate, _) in predicates.predicates {
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::RegionOutlives(_) ty::PredicateKind::RegionOutlives(_)
| ty::PredicateAtom::TypeOutlives(_) | ty::PredicateKind::TypeOutlives(_)
| ty::PredicateAtom::WellFormed(_) | ty::PredicateKind::WellFormed(_)
| ty::PredicateAtom::Projection(_) | ty::PredicateKind::Projection(_)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => continue, | ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
ty::PredicateAtom::ObjectSafe(_) => { ty::PredicateKind::ObjectSafe(_) => {
bug!("object safe predicate on function: {:#?}", predicate) bug!("object safe predicate on function: {:#?}", predicate)
} }
ty::PredicateAtom::ClosureKind(..) => { ty::PredicateKind::ClosureKind(..) => {
bug!("closure kind predicate on function: {:#?}", predicate) bug!("closure kind predicate on function: {:#?}", predicate)
} }
ty::PredicateAtom::Subtype(_) => { ty::PredicateKind::Subtype(_) => {
bug!("subtype predicate on function: {:#?}", predicate) 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() { if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
continue; continue;
} }

View file

@ -5,7 +5,7 @@ use rustc_middle::mir::*;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, self,
subst::{GenericArgKind, Subst, SubstsRef}, subst::{GenericArgKind, Subst, SubstsRef},
PredicateAtom, Ty, TyCtxt, TyS, PredicateKind, Ty, TyCtxt, TyS,
}; };
use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES; use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES;
use rustc_span::{symbol::sym, Span}; 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 param_env = self.tcx.param_env(def_id);
let bounds = param_env.caller_bounds(); let bounds = param_env.caller_bounds();
for bound in 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. // Get the argument types as they appear in the function signature.
let arg_defs = self.tcx.fn_sig(def_id).skip_binder().inputs(); let arg_defs = self.tcx.fn_sig(def_id).skip_binder().inputs();
for (arg_num, arg_def) in arg_defs.iter().enumerate() { 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. /// 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>> { fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
if let ty::PredicateAtom::Trait(predicate, _) = bound { if let ty::PredicateKind::Trait(predicate, _) = bound {
if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) { if self.tcx.is_diagnostic_item(sym::pointer_trait, predicate.def_id()) {
Some(predicate.trait_ref.self_ty()) Some(predicate.trait_ref.self_ty())
} else { } else {

View file

@ -100,19 +100,19 @@ where
} }
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> { fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::BreakTy> {
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(ty::TraitPredicate { trait_ref }, _) => { ty::PredicateKind::Trait(ty::TraitPredicate { trait_ref }, _) => {
self.visit_trait(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)?; ty.visit_with(self)?;
self.visit_trait(projection_ty.trait_ref(self.def_id_visitor.tcx())) 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.visit_with(self)
} }
ty::PredicateAtom::RegionOutlives(..) => ControlFlow::CONTINUE, ty::PredicateKind::RegionOutlives(..) => ControlFlow::CONTINUE,
ty::PredicateAtom::ConstEvaluatable(..) ty::PredicateKind::ConstEvaluatable(..)
if self.def_id_visitor.tcx().features().const_evaluatable_checked => if self.def_id_visitor.tcx().features().const_evaluatable_checked =>
{ {
// FIXME(const_evaluatable_checked): If the constant used here depends on a // FIXME(const_evaluatable_checked): If the constant used here depends on a

View file

@ -1153,7 +1153,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
debug!("instantiate_opaque_types: ty_var={:?}", ty_var); debug!("instantiate_opaque_types: ty_var={:?}", ty_var);
for predicate in &bounds { 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() { if projection.ty.references_error() {
// No point on adding these obligations since there's a type error involved. // No point on adding these obligations since there's a type error involved.
return ty_var; return ty_var;
@ -1251,18 +1251,18 @@ crate fn required_region_bounds(
traits::elaborate_predicates(tcx, predicates) traits::elaborate_predicates(tcx, predicates)
.filter_map(|obligation| { .filter_map(|obligation| {
debug!("required_region_bounds(obligation={:?})", obligation); debug!("required_region_bounds(obligation={:?})", obligation);
match obligation.predicate.skip_binders() { match obligation.predicate.kind().skip_binder() {
ty::PredicateAtom::Projection(..) ty::PredicateKind::Projection(..)
| ty::PredicateAtom::Trait(..) | ty::PredicateKind::Trait(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::RegionOutlives(..) | ty::PredicateKind::RegionOutlives(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None, | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => { ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
// Search for a bound of the form `erased_self_ty // Search for a bound of the form `erased_self_ty
// : 'a`, but be wary of something like `for<'a> // : 'a`, but be wary of something like `for<'a>
// erased_self_ty : 'a` (we interpret a // erased_self_ty : 'a` (we interpret a

View file

@ -414,9 +414,9 @@ impl AutoTraitFinder<'tcx> {
let mut should_add_new = true; let mut should_add_new = true;
user_computed_preds.retain(|&old_pred| { user_computed_preds.retain(|&old_pred| {
if let ( if let (
ty::PredicateAtom::Trait(new_trait, _), ty::PredicateKind::Trait(new_trait, _),
ty::PredicateAtom::Trait(old_trait, _), ty::PredicateKind::Trait(old_trait, _),
) = (new_pred.skip_binders(), old_pred.skip_binders()) ) = (new_pred.kind().skip_binder(), old_pred.kind().skip_binder())
{ {
if new_trait.def_id() == old_trait.def_id() { if new_trait.def_id() == old_trait.def_id() {
let new_substs = new_trait.trait_ref.substs; 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 // We check this by calling is_of_param on the relevant types
// from the various possible predicates // from the various possible predicates
let bound_predicate = predicate.bound_atom(); let bound_predicate = predicate.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(p, _) => { ty::PredicateKind::Trait(p, _) => {
// Add this to `predicates` so that we end up calling `select` // Add this to `predicates` so that we end up calling `select`
// with it. If this predicate ends up being unimplemented, // with it. If this predicate ends up being unimplemented,
// then `evaluate_predicates` will handle adding it the `ParamEnv` // then `evaluate_predicates` will handle adding it the `ParamEnv`
// if possible. // if possible.
predicates.push_back(bound_predicate.rebind(p)); predicates.push_back(bound_predicate.rebind(p));
} }
ty::PredicateAtom::Projection(p) => { ty::PredicateKind::Projection(p) => {
let p = bound_predicate.rebind(p); let p = bound_predicate.rebind(p);
debug!( debug!(
"evaluate_nested_obligations: examining projection predicate {:?}", "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); let binder = bound_predicate.rebind(binder);
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() { if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
return false; return false;
} }
} }
ty::PredicateAtom::TypeOutlives(binder) => { ty::PredicateKind::TypeOutlives(binder) => {
let binder = bound_predicate.rebind(binder); let binder = bound_predicate.rebind(binder);
match ( match (
binder.no_bound_vars(), 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>| { let evaluate = |c: &'tcx ty::Const<'tcx>| {
if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val { if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val {
match select.infcx().const_eval_resolve( match select.infcx().const_eval_resolve(

View file

@ -41,8 +41,8 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
// We are looking at a generic abstract constant. // We are looking at a generic abstract constant.
Some(ct) => { Some(ct) => {
for pred in param_env.caller_bounds() { for pred in param_env.caller_bounds() {
match pred.skip_binders() { match pred.kind().skip_binder() {
ty::PredicateAtom::ConstEvaluatable(b_def, b_substs) => { ty::PredicateKind::ConstEvaluatable(b_def, b_substs) => {
debug!( debug!(
"is_const_evaluatable: caller_bound={:?}, {:?}", "is_const_evaluatable: caller_bound={:?}, {:?}",
b_def, b_substs b_def, b_substs

View file

@ -256,9 +256,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return; return;
} }
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() { 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 = bound_predicate.rebind(trait_predicate);
let trait_predicate = self.resolve_vars_if_possible(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 err
} }
ty::PredicateAtom::Subtype(predicate) => { ty::PredicateKind::Subtype(predicate) => {
// Errors for Subtype predicates show up as // Errors for Subtype predicates show up as
// `FulfillmentErrorCode::CodeSubtypeError`, // `FulfillmentErrorCode::CodeSubtypeError`,
// not selection error. // not selection error.
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate) 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 = bound_predicate.rebind(predicate);
let predicate = self.resolve_vars_if_possible(predicate); let predicate = self.resolve_vars_if_possible(predicate);
let err = self 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); let predicate = self.resolve_vars_if_possible(obligation.predicate);
struct_span_err!( struct_span_err!(
self.tcx.sess, 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); let violations = self.tcx.object_safety_violations(trait_def_id);
report_object_safety_error(self.tcx, span, trait_def_id, violations) 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 found_kind = self.closure_kind(closure_substs).unwrap();
let closure_span = let closure_span =
self.tcx.sess.source_map().guess_head_span( self.tcx.sess.source_map().guess_head_span(
@ -617,7 +617,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return; return;
} }
ty::PredicateAtom::WellFormed(ty) => { ty::PredicateKind::WellFormed(ty) => {
if !self.tcx.sess.opts.debugging_opts.chalk { if !self.tcx.sess.opts.debugging_opts.chalk {
// WF predicates cannot themselves make // WF predicates cannot themselves make
// errors. They can only block due to // 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 // Errors for `ConstEvaluatable` predicates show up as
// `SelectionError::ConstEvalFailure`, // `SelectionError::ConstEvalFailure`,
// not `Unimplemented`. // 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 // Errors for `ConstEquate` predicates show up as
// `SelectionError::ConstEvalFailure`, // `SelectionError::ConstEvalFailure`,
// not `Unimplemented`. // 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, span,
"TypeWellFormedFromEnv predicate should only exist in the environment" "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. // FIXME: It should be possible to deal with `ForAll` in a cleaner way.
let bound_error = error.bound_atom(); let bound_error = error.kind();
let (cond, error) = match (cond.skip_binders(), bound_error.skip_binder()) { let (cond, error) = match (cond.kind().skip_binder(), bound_error.skip_binder()) {
(ty::PredicateAtom::Trait(..), ty::PredicateAtom::Trait(error, _)) => { (ty::PredicateKind::Trait(..), ty::PredicateKind::Trait(error, _)) => {
(cond, bound_error.rebind(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)) { for obligation in super::elaborate_predicates(self.tcx, std::iter::once(cond)) {
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
if let ty::PredicateAtom::Trait(implication, _) = bound_predicate.skip_binder() { if let ty::PredicateKind::Trait(implication, _) = bound_predicate.skip_binder() {
let error = error.to_poly_trait_ref(); let error = error.to_poly_trait_ref();
let implication = bound_predicate.rebind(implication.trait_ref); let implication = bound_predicate.rebind(implication.trait_ref);
// FIXME: I'm just not taking associated types at all here. // 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 // this can fail if the problem was higher-ranked, in which
// cause I have no idea for a good error message. // cause I have no idea for a good error message.
let bound_predicate = predicate.bound_atom(); let bound_predicate = predicate.kind();
if let ty::PredicateAtom::Projection(data) = bound_predicate.skip_binder() { if let ty::PredicateKind::Projection(data) = bound_predicate.skip_binder() {
let mut selcx = SelectionContext::new(self); let mut selcx = SelectionContext::new(self);
let (data, _) = self.replace_bound_vars_with_fresh_vars( let (data, _) = self.replace_bound_vars_with_fresh_vars(
obligation.cause.span, obligation.cause.span,
@ -1452,9 +1452,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
return; return;
} }
let bound_predicate = predicate.bound_atom(); let bound_predicate = predicate.kind();
let mut err = match bound_predicate.skip_binder() { 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); let trait_ref = bound_predicate.rebind(data.trait_ref);
debug!("trait_ref {:?}", trait_ref); debug!("trait_ref {:?}", trait_ref);
@ -1559,7 +1559,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
err err
} }
ty::PredicateAtom::WellFormed(arg) => { ty::PredicateKind::WellFormed(arg) => {
// Same hacky approach as above to avoid deluging user // Same hacky approach as above to avoid deluging user
// with error messages. // with error messages.
if arg.references_error() || self.tcx.sess.has_errors() { 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) 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() { if data.references_error() || self.tcx.sess.has_errors() {
// no need to overload user in such cases // no need to overload user in such cases
return; return;
@ -1579,7 +1579,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
assert!(a.is_ty_var() && b.is_ty_var()); assert!(a.is_ty_var() && b.is_ty_var());
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282) 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 trait_ref = bound_predicate.rebind(data).to_poly_trait_ref(self.tcx);
let self_ty = trait_ref.skip_binder().self_ty(); let self_ty = trait_ref.skip_binder().self_ty();
let ty = data.ty; let ty = data.ty;
@ -1709,9 +1709,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
obligation: &PredicateObligation<'tcx>, obligation: &PredicateObligation<'tcx>,
) { ) {
let (pred, item_def_id, span) = 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), &ObligationCauseCode::BindingObligation(item_def_id, span),
) => (pred, item_def_id, span), ) => (pred, item_def_id, span),
_ => return, _ => return,

View file

@ -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 // 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 // bound was introduced. At least one generator should be present for this diagnostic to be
// modified. // modified.
let (mut trait_ref, mut target_ty) = match obligation.predicate.skip_binders() { let (mut trait_ref, mut target_ty) = match obligation.predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())), ty::PredicateKind::Trait(p, _) => (Some(p.trait_ref), Some(p.self_ty())),
_ => (None, None), _ => (None, None),
}; };
let mut generator = None; let mut generator = None;

View file

@ -345,13 +345,13 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
let infcx = self.selcx.infcx(); let infcx = self.selcx.infcx();
let binder = obligation.predicate.bound_atom(); let binder = obligation.predicate.kind();
if binder.skip_binder().has_escaping_bound_vars() { match binder.no_bound_vars() {
match binder.skip_binder() { None => match binder.skip_binder() {
// Evaluation will discard candidates using the leak check. // Evaluation will discard candidates using the leak check.
// This means we need to pass it the bound version of our // This means we need to pass it the bound version of our
// predicate. // predicate.
ty::PredicateAtom::Trait(trait_ref, _constness) => { ty::PredicateKind::Trait(trait_ref, _constness) => {
let trait_obligation = obligation.with(binder.rebind(trait_ref)); let trait_obligation = obligation.with(binder.rebind(trait_ref));
self.process_trait_obligation( self.process_trait_obligation(
@ -360,7 +360,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
&mut pending_obligation.stalled_on, &mut pending_obligation.stalled_on,
) )
} }
ty::PredicateAtom::Projection(data) => { ty::PredicateKind::Projection(data) => {
let project_obligation = obligation.with(binder.rebind(data)); let project_obligation = obligation.with(binder.rebind(data));
self.process_projection_obligation( self.process_projection_obligation(
@ -368,26 +368,25 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
&mut pending_obligation.stalled_on, &mut pending_obligation.stalled_on,
) )
} }
ty::PredicateAtom::RegionOutlives(_) ty::PredicateKind::RegionOutlives(_)
| ty::PredicateAtom::TypeOutlives(_) | ty::PredicateKind::TypeOutlives(_)
| ty::PredicateAtom::WellFormed(_) | ty::PredicateKind::WellFormed(_)
| ty::PredicateAtom::ObjectSafe(_) | ty::PredicateKind::ObjectSafe(_)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(_) | ty::PredicateKind::Subtype(_)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) => { | ty::PredicateKind::ConstEquate(..) => {
let pred = infcx.replace_bound_vars_with_placeholders(binder); let pred = infcx.replace_bound_vars_with_placeholders(binder);
ProcessResult::Changed(mk_pending(vec![ ProcessResult::Changed(mk_pending(vec![
obligation.with(pred.to_predicate(self.selcx.tcx())), obligation.with(pred.to_predicate(self.selcx.tcx())),
])) ]))
} }
ty::PredicateAtom::TypeWellFormedFromEnv(..) => { ty::PredicateKind::TypeWellFormedFromEnv(..) => {
bug!("TypeWellFormedFromEnv is only used for Chalk") bug!("TypeWellFormedFromEnv is only used for Chalk")
} }
} },
} else { Some(pred) => match pred {
match binder.skip_binder() { ty::PredicateKind::Trait(data, _) => {
ty::PredicateAtom::Trait(data, _) => {
let trait_obligation = obligation.with(Binder::dummy(data)); let trait_obligation = obligation.with(Binder::dummy(data));
self.process_trait_obligation( 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)) { match infcx.region_outlives_predicate(&obligation.cause, Binder::dummy(data)) {
Ok(()) => ProcessResult::Changed(vec![]), Ok(()) => ProcessResult::Changed(vec![]),
Err(_) => ProcessResult::Error(CodeSelectionError(Unimplemented)), 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 { if self.register_region_obligations {
self.selcx.infcx().register_region_obligation_with_cause( self.selcx.infcx().register_region_obligation_with_cause(
t_a, t_a,
@ -415,7 +414,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
ProcessResult::Changed(vec![]) ProcessResult::Changed(vec![])
} }
ty::PredicateAtom::Projection(ref data) => { ty::PredicateKind::Projection(ref data) => {
let project_obligation = obligation.with(Binder::dummy(*data)); let project_obligation = obligation.with(Binder::dummy(*data));
self.process_projection_obligation( 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) { if !self.selcx.tcx().is_object_safe(trait_def_id) {
ProcessResult::Error(CodeSelectionError(Unimplemented)) ProcessResult::Error(CodeSelectionError(Unimplemented))
} else { } 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) { match self.selcx.infcx().closure_kind(closure_substs) {
Some(closure_kind) => { Some(closure_kind) => {
if closure_kind.extends(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( match wf::obligations(
self.selcx.infcx(), self.selcx.infcx(),
obligation.param_env, 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( match self.selcx.infcx().subtype_predicate(
&obligation.cause, &obligation.cause,
obligation.param_env, 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( match const_evaluatable::is_const_evaluatable(
self.selcx.infcx(), self.selcx.infcx(),
def_id, 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"); debug!(?c1, ?c2, "equating consts");
if self.selcx.tcx().features().const_evaluatable_checked { if self.selcx.tcx().features().const_evaluatable_checked {
// FIXME: we probably should only try to unify abstract constants // 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") bug!("TypeWellFormedFromEnv is only used for Chalk")
} }
} },
} }
} }

View file

@ -324,7 +324,7 @@ pub fn normalize_param_env_or_error<'tcx>(
// TypeOutlives predicates - these are normally used by regionck. // TypeOutlives predicates - these are normally used by regionck.
let outlives_predicates: Vec<_> = predicates let outlives_predicates: Vec<_> = predicates
.drain_filter(|predicate| { .drain_filter(|predicate| {
matches!(predicate.skip_binders(), ty::PredicateAtom::TypeOutlives(..)) matches!(predicate.kind().skip_binder(), ty::PredicateKind::TypeOutlives(..))
}) })
.collect(); .collect();

View file

@ -273,12 +273,12 @@ fn predicate_references_self(
) -> Option<Span> { ) -> Option<Span> {
let self_ty = tcx.types.self_param; let self_ty = tcx.types.self_param;
let has_self_ty = |arg: &GenericArg<'_>| arg.walk().any(|arg| arg == self_ty.into()); let has_self_ty = |arg: &GenericArg<'_>| arg.walk().any(|arg| arg == self_ty.into());
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(ref data, _) => { ty::PredicateKind::Trait(ref data, _) => {
// In the case of a trait predicate, we can skip the "self" type. // 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 } 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 // And similarly for projections. This should be redundant with
// the previous check because any projection should have a // the previous check because any projection should have a
// matching `Trait` predicate with the same inputs, but we do // matching `Trait` predicate with the same inputs, but we do
@ -300,15 +300,15 @@ fn predicate_references_self(
None None
} }
} }
ty::PredicateAtom::WellFormed(..) ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::TypeOutlives(..) | ty::PredicateKind::TypeOutlives(..)
| ty::PredicateAtom::RegionOutlives(..) | ty::PredicateKind::RegionOutlives(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None, | 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 = tcx.predicates_of(def_id);
let predicates = predicates.instantiate_identity(tcx).predicates; let predicates = predicates.instantiate_identity(tcx).predicates;
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| { elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| {
match obligation.predicate.skip_binders() { match obligation.predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(ref trait_pred, _) => { ty::PredicateKind::Trait(ref trait_pred, _) => {
trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0) trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0)
} }
ty::PredicateAtom::Projection(..) ty::PredicateKind::Projection(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::RegionOutlives(..) | ty::PredicateKind::RegionOutlives(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::TypeOutlives(..) | ty::PredicateKind::TypeOutlives(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => false, | 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> { 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 // FIXME(const_evaluatable_checked): We should probably deduplicate the logic for
// `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to // `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to
// take a `ty::Const` instead. // take a `ty::Const` instead.

View file

@ -625,7 +625,7 @@ fn prune_cache_value_obligations<'a, 'tcx>(
.obligations .obligations
.iter() .iter()
.filter(|obligation| { .filter(|obligation| {
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
// We found a `T: Foo<X = U>` predicate, let's check // We found a `T: Foo<X = U>` predicate, let's check
// if `U` references any unresolved type // 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`, // indirect obligations (e.g., we project to `?0`,
// but we have `T: Foo<X = ?1>` and `?1: Bar<X = // but we have `T: Foo<X = ?1>` and `?1: Bar<X =
// ?0>`). // ?0>`).
ty::PredicateAtom::Projection(data) => { ty::PredicateKind::Projection(data) => {
infcx.unresolved_type_vars(&bound_predicate.rebind(data.ty)).is_some() 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(); let infcx = selcx.infcx();
for predicate in env_predicates { for predicate in env_predicates {
debug!(?predicate); debug!(?predicate);
let bound_predicate = predicate.bound_atom(); let bound_predicate = predicate.kind();
if let ty::PredicateAtom::Projection(data) = predicate.skip_binders() { if let ty::PredicateKind::Projection(data) = predicate.kind().skip_binder() {
let data = bound_predicate.rebind(data); let data = bound_predicate.rebind(data);
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id; let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id;

View file

@ -15,7 +15,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
// `&T`, accounts for about 60% percentage of the predicates // `&T`, accounts for about 60% percentage of the predicates
// we have to prove. No need to canonicalize and all that for // we have to prove. No need to canonicalize and all that for
// such cases. // 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 let Some(sized_def_id) = tcx.lang_items().sized_trait() {
if trait_ref.def_id() == sized_def_id { if trait_ref.def_id() == sized_def_id {
if trait_ref.self_ty().is_trivially_sized(tcx) { if trait_ref.self_ty().is_trivially_sized(tcx) {

View file

@ -432,7 +432,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.predicates .predicates
.into_iter() .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( let normalized_super_trait = normalize_with_depth_to(
self, self,
obligation.param_env, obligation.param_env,
@ -641,7 +641,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligations.push(Obligation::new( obligations.push(Obligation::new(
obligation.cause.clone(), obligation.cause.clone(),
obligation.param_env, obligation.param_env,
ty::PredicateAtom::ClosureKind(closure_def_id, substs, kind) ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)
.to_predicate(self.tcx()), .to_predicate(self.tcx()),
)); ));
} }

View file

@ -454,16 +454,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
let result = ensure_sufficient_stack(|| { let result = ensure_sufficient_stack(|| {
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(t, _) => { ty::PredicateKind::Trait(t, _) => {
let t = bound_predicate.rebind(t); let t = bound_predicate.rebind(t);
debug_assert!(!t.has_escaping_bound_vars()); debug_assert!(!t.has_escaping_bound_vars());
let obligation = obligation.with(t); let obligation = obligation.with(t);
self.evaluate_trait_predicate_recursively(previous_stack, obligation) self.evaluate_trait_predicate_recursively(previous_stack, obligation)
} }
ty::PredicateAtom::Subtype(p) => { ty::PredicateKind::Subtype(p) => {
let p = bound_predicate.rebind(p); let p = bound_predicate.rebind(p);
// Does this code ever run? // Does this code ever run?
match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) { 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, self.infcx,
obligation.param_env, obligation.param_env,
obligation.cause.body_id, obligation.cause.body_id,
@ -494,12 +494,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
None => Ok(EvaluatedToAmbig), 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. // We do not consider region relationships when evaluating trait matches.
Ok(EvaluatedToOkModuloRegions) Ok(EvaluatedToOkModuloRegions)
} }
ty::PredicateAtom::ObjectSafe(trait_def_id) => { ty::PredicateKind::ObjectSafe(trait_def_id) => {
if self.tcx().is_object_safe(trait_def_id) { if self.tcx().is_object_safe(trait_def_id) {
Ok(EvaluatedToOk) Ok(EvaluatedToOk)
} else { } 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 data = bound_predicate.rebind(data);
let project_obligation = obligation.with(data); let project_obligation = obligation.with(data);
match project::poly_project_and_unify_type(self, &project_obligation) { 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) { match self.infcx.closure_kind(closure_substs) {
Some(closure_kind) => { Some(closure_kind) => {
if closure_kind.extends(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( match const_evaluatable::is_const_evaluatable(
self.infcx, self.infcx,
def_id, 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"); debug!(?c1, ?c2, "evaluate_predicate_recursively: equating consts");
let evaluate = |c: &'tcx ty::Const<'tcx>| { 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") 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 { fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
let result = match predicate.skip_binders() { let result = match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()), ty::PredicateKind::Trait(ref data, _) => self.tcx().trait_is_auto(data.def_id()),
_ => false, _ => false,
}; };
debug!(?predicate, ?result, "coinductive_predicate"); debug!(?predicate, ?result, "coinductive_predicate");
@ -1174,8 +1174,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.iter() .iter()
.enumerate() .enumerate()
.filter_map(|(idx, bound)| { .filter_map(|(idx, bound)| {
let bound_predicate = bound.bound_atom(); let bound_predicate = bound.kind();
if let ty::PredicateAtom::Trait(pred, _) = bound_predicate.skip_binder() { if let ty::PredicateKind::Trait(pred, _) = bound_predicate.skip_binder() {
let bound = bound_predicate.rebind(pred.trait_ref); let bound = bound_predicate.rebind(pred.trait_ref);
if self.infcx.probe(|_| { if self.infcx.probe(|_| {
match self.match_normalize_trait_ref( match self.match_normalize_trait_ref(

View file

@ -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 // It's ok to skip the binder here because wf code is prepared for it
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(t, _) => { ty::PredicateKind::Trait(t, _) => {
wf.compute_trait_ref(&t.trait_ref, Elaborate::None); wf.compute_trait_ref(&t.trait_ref, Elaborate::None);
} }
ty::PredicateAtom::RegionOutlives(..) => {} ty::PredicateKind::RegionOutlives(..) => {}
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => { ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _reg)) => {
wf.compute(ty.into()); wf.compute(ty.into());
} }
ty::PredicateAtom::Projection(t) => { ty::PredicateKind::Projection(t) => {
wf.compute_projection(t.projection_ty); wf.compute_projection(t.projection_ty);
wf.compute(t.ty.into()); wf.compute(t.ty.into());
} }
ty::PredicateAtom::WellFormed(arg) => { ty::PredicateKind::WellFormed(arg) => {
wf.compute(arg); wf.compute(arg);
} }
ty::PredicateAtom::ObjectSafe(_) => {} ty::PredicateKind::ObjectSafe(_) => {}
ty::PredicateAtom::ClosureKind(..) => {} ty::PredicateKind::ClosureKind(..) => {}
ty::PredicateAtom::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => { ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ }) => {
wf.compute(a.into()); wf.compute(a.into());
wf.compute(b.into()); wf.compute(b.into());
} }
ty::PredicateAtom::ConstEvaluatable(def, substs) => { ty::PredicateKind::ConstEvaluatable(def, substs) => {
let obligations = wf.nominal_obligations(def.did, substs); let obligations = wf.nominal_obligations(def.did, substs);
wf.out.extend(obligations); wf.out.extend(obligations);
@ -135,11 +135,11 @@ pub fn predicate_obligations<'a, 'tcx>(
wf.compute(arg); wf.compute(arg);
} }
} }
ty::PredicateAtom::ConstEquate(c1, c2) => { ty::PredicateKind::ConstEquate(c1, c2) => {
wf.compute(c1.into()); wf.compute(c1.into());
wf.compute(c2.into()); wf.compute(c2.into());
} }
ty::PredicateAtom::TypeWellFormedFromEnv(..) => { ty::PredicateKind::TypeWellFormedFromEnv(..) => {
bug!("TypeWellFormedFromEnv is only used for Chalk") 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. // It is fine to skip the binder as we don't care about regions here.
match pred.skip_binders() { match pred.kind().skip_binder() {
ty::PredicateAtom::Projection(proj) => { ty::PredicateKind::Projection(proj) => {
// The obligation comes not from the current `impl` nor the `trait` being implemented, // 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 // but rather from a "second order" obligation, where an associated type has a
// projection coming from another associated type. See // 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 // 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`. // 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); debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
@ -343,7 +343,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
new_cause, new_cause,
depth, depth,
param_env, 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(), cause.clone(),
depth, depth,
param_env, 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); let obligations = self.nominal_obligations(def.did, substs);
self.out.extend(obligations); self.out.extend(obligations);
let predicate = ty::PredicateAtom::ConstEvaluatable(def, substs) let predicate = ty::PredicateKind::ConstEvaluatable(def, substs)
.to_predicate(self.tcx()); .to_predicate(self.tcx());
let cause = self.cause(traits::MiscObligation); let cause = self.cause(traits::MiscObligation);
self.out.push(traits::Obligation::with_depth( self.out.push(traits::Obligation::with_depth(
@ -460,7 +460,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause, cause,
self.recursion_depth, self.recursion_depth,
self.param_env, self.param_env,
ty::PredicateAtom::WellFormed(resolved_constant.into()) ty::PredicateKind::WellFormed(resolved_constant.into())
.to_predicate(self.tcx()), .to_predicate(self.tcx()),
)); ));
} }
@ -547,7 +547,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause, cause,
depth, depth,
param_env, param_env,
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(rty, r)) ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(rty, r))
.to_predicate(self.tcx()), .to_predicate(self.tcx()),
)); ));
} }
@ -637,7 +637,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
cause.clone(), cause.clone(),
depth, depth,
param_env, 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, cause,
self.recursion_depth, self.recursion_depth,
param_env, param_env,
ty::PredicateAtom::WellFormed(ty.into()).to_predicate(self.tcx()), ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()),
)); ));
} else { } else {
// Yes, resolved, proceed with the result. // Yes, resolved, proceed with the result.

View file

@ -82,35 +82,35 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
) -> chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'tcx>>> { ) -> chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'tcx>>> {
let clauses = self.environment.into_iter().map(|predicate| { let clauses = self.environment.into_iter().map(|predicate| {
let (predicate, binders, _named_regions) = 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 { let consequence = match predicate {
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => { ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner))) 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)), 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 { chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
a: predicate.0.lower_into(interner), a: predicate.0.lower_into(interner),
b: predicate.1.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 { chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
ty: predicate.0.lower_into(interner), ty: predicate.0.lower_into(interner),
lifetime: predicate.1.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)), chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
), ),
ty::PredicateAtom::WellFormed(..) ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) => bug!("unexpected predicate {}", predicate), | ty::PredicateKind::ConstEquate(..) => bug!("unexpected predicate {}", predicate),
}; };
let value = chalk_ir::ProgramClauseImplication { let value = chalk_ir::ProgramClauseImplication {
consequence, 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> { 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>> { fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
let (predicate, binders, _named_regions) = 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 { let value = match predicate {
ty::PredicateAtom::Trait(predicate, _) => { ty::PredicateKind::Trait(predicate, _) => {
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds( chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)), 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::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives { chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
a: predicate.0.lower_into(interner), 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::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives { chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
ty: predicate.0.lower_into(interner), 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::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)), 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() { GenericArgKind::Type(ty) => match ty.kind() {
// FIXME(chalk): In Chalk, a placeholder is WellFormed if it // FIXME(chalk): In Chalk, a placeholder is WellFormed if it
// `FromEnv`. However, when we "lower" Params, we don't update // `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), 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)), 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 // We can defer this, but ultimately we'll want to express
// some of these in terms of chalk operations. // some of these in terms of chalk operations.
ty::PredicateAtom::ClosureKind(..) ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) => { | ty::PredicateKind::ConstEquate(..) => {
chalk_ir::GoalData::All(chalk_ir::Goals::empty(interner)) 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))), 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>, interner: &RustInterner<'tcx>,
) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> { ) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> {
let (predicate, binders, _named_regions) = 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 { let value = match predicate {
ty::PredicateAtom::Trait(predicate, _) => { ty::PredicateKind::Trait(predicate, _) => {
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner))) 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 { Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
a: predicate.0.lower_into(interner), a: predicate.0.lower_into(interner),
b: predicate.1.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 { Some(chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
ty: predicate.0.lower_into(interner), ty: predicate.0.lower_into(interner),
lifetime: predicate.1.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))) Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
} }
ty::PredicateAtom::WellFormed(_ty) => None, ty::PredicateKind::WellFormed(_ty) => None,
ty::PredicateAtom::ObjectSafe(..) ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => { | ty::PredicateKind::TypeWellFormedFromEnv(..) => {
bug!("unexpected predicate {}", &self) bug!("unexpected predicate {}", &self)
} }
}; };
@ -699,28 +699,28 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
interner: &RustInterner<'tcx>, interner: &RustInterner<'tcx>,
) -> Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>> { ) -> Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>> {
let (predicate, binders, _named_regions) = let (predicate, binders, _named_regions) =
collect_bound_vars(interner, interner.tcx, self.bound_atom()); collect_bound_vars(interner, interner.tcx, self.kind());
match predicate { match predicate {
ty::PredicateAtom::Trait(predicate, _) => Some(chalk_ir::Binders::new( ty::PredicateKind::Trait(predicate, _) => Some(chalk_ir::Binders::new(
binders, binders,
chalk_solve::rust_ir::InlineBound::TraitBound( chalk_solve::rust_ir::InlineBound::TraitBound(
predicate.trait_ref.lower_into(interner), 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, binders,
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)), chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
)), )),
ty::PredicateAtom::TypeOutlives(_predicate) => None, ty::PredicateKind::TypeOutlives(_predicate) => None,
ty::PredicateAtom::WellFormed(_ty) => None, ty::PredicateKind::WellFormed(_ty) => None,
ty::PredicateAtom::RegionOutlives(..) ty::PredicateKind::RegionOutlives(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => { | ty::PredicateKind::TypeWellFormedFromEnv(..) => {
bug!("unexpected predicate {}", &self) bug!("unexpected predicate {}", &self)
} }
} }

View file

@ -94,27 +94,27 @@ fn compute_implied_outlives_bounds<'tcx>(
// region relationships. // region relationships.
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| { implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
assert!(!obligation.has_escaping_bound_vars()); assert!(!obligation.has_escaping_bound_vars());
match obligation.predicate.bound_atom().no_bound_vars() { match obligation.predicate.kind().no_bound_vars() {
None => vec![], None => vec![],
Some(pred) => match pred { Some(pred) => match pred {
ty::PredicateAtom::Trait(..) ty::PredicateKind::Trait(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::Projection(..) | ty::PredicateKind::Projection(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => vec![], | ty::PredicateKind::TypeWellFormedFromEnv(..) => vec![],
ty::PredicateAtom::WellFormed(arg) => { ty::PredicateKind::WellFormed(arg) => {
wf_args.push(arg); wf_args.push(arg);
vec![] 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)] 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 ty_a = infcx.resolve_vars_if_possible(ty_a);
let mut components = smallvec![]; let mut components = smallvec![];
tcx.push_outlives_components(ty_a, &mut components); tcx.push_outlives_components(ty_a, &mut components);

View file

@ -46,16 +46,16 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>(
} }
fn not_outlives_predicate(p: &ty::Predicate<'tcx>) -> bool { fn not_outlives_predicate(p: &ty::Predicate<'tcx>) -> bool {
match p.skip_binders() { match p.kind().skip_binder() {
ty::PredicateAtom::RegionOutlives(..) | ty::PredicateAtom::TypeOutlives(..) => false, ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
ty::PredicateAtom::Trait(..) ty::PredicateKind::Trait(..)
| ty::PredicateAtom::Projection(..) | ty::PredicateKind::Projection(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => true, | ty::PredicateKind::TypeWellFormedFromEnv(..) => true,
} }
} }

View file

@ -140,7 +140,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
self.relate(self_ty, Variance::Invariant, impl_self_ty)?; self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
self.prove_predicate( self.prove_predicate(
ty::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 // them? This would only be relevant if some input
// type were ill-formed but did not appear in `ty`, // type were ill-formed but did not appear in `ty`,
// which...could happen with normalization... // which...could happen with normalization...
self.prove_predicate(ty::PredicateAtom::WellFormed(ty.into()).to_predicate(self.tcx())); self.prove_predicate(ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()));
Ok(()) Ok(())
} }
} }

View file

@ -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::hir::map as hir_map;
use rustc_middle::ty::subst::Subst; use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{ 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_session::CrateDisambiguator;
use rustc_span::symbol::Symbol; 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| { let input_clauses = inputs.into_iter().filter_map(|arg| {
match arg.unpack() { match arg.unpack() {
GenericArgKind::Type(ty) => { GenericArgKind::Type(ty) => {
let binder = Binder::dummy(PredicateAtom::TypeWellFormedFromEnv(ty)); let binder = Binder::dummy(PredicateKind::TypeWellFormedFromEnv(ty));
Some(tcx.mk_predicate(binder)) Some(tcx.mk_predicate(binder))
} }

View file

@ -1177,9 +1177,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
obligation.predicate obligation.predicate
); );
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(pred, _) => { ty::PredicateKind::Trait(pred, _) => {
let pred = bound_predicate.rebind(pred); let pred = bound_predicate.rebind(pred);
associated_types.entry(span).or_default().extend( associated_types.entry(span).or_default().extend(
tcx.associated_items(pred.def_id()) tcx.associated_items(pred.def_id())
@ -1188,7 +1188,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.map(|item| item.def_id), .map(|item| item.def_id),
); );
} }
ty::PredicateAtom::Projection(pred) => { ty::PredicateKind::Projection(pred) => {
let pred = bound_predicate.rebind(pred); let pred = bound_predicate.rebind(pred);
// A `Self` within the original bound will be substituted with a // A `Self` within the original bound will be substituted with a
// `trait_object_dummy_self`, so check for that. // `trait_object_dummy_self`, so check for that.

View file

@ -544,9 +544,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.infcx.instantiate_opaque_types(id, self.body_id, self.param_env, ty, span); 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(); let mut suggest_box = !impl_trait_ret_ty.obligations.is_empty();
for o in impl_trait_ret_ty.obligations { for o in impl_trait_ret_ty.obligations {
match o.predicate.bound_atom().skip_binder() { match o.predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(t, constness) => { ty::PredicateKind::Trait(t, constness) => {
let pred = ty::PredicateAtom::Trait( let pred = ty::PredicateKind::Trait(
ty::TraitPredicate { ty::TraitPredicate {
trait_ref: ty::TraitRef { trait_ref: ty::TraitRef {
def_id: t.def_id(), def_id: t.def_id(),

View file

@ -192,9 +192,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
obligation.predicate obligation.predicate
); );
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
if let ty::PredicateAtom::Projection(proj_predicate) = if let ty::PredicateKind::Projection(proj_predicate) =
obligation.predicate.skip_binders() obligation.predicate.kind().skip_binder()
{ {
// Given a Projection predicate, we can potentially infer // Given a Projection predicate, we can potentially infer
// the complete signature. // 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` // where R is the return type we are expecting. This type `T`
// will be our output. // will be our output.
let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| { let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| {
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
if let ty::PredicateAtom::Projection(proj_predicate) = bound_predicate.skip_binder() { if let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() {
self.deduce_future_output_from_projection( self.deduce_future_output_from_projection(
obligation.cause.span, obligation.cause.span,
bound_predicate.rebind(proj_predicate), bound_predicate.rebind(proj_predicate),

View file

@ -583,9 +583,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
while !queue.is_empty() { while !queue.is_empty() {
let obligation = queue.remove(0); let obligation = queue.remove(0);
debug!("coerce_unsized resolve step: {:?}", obligation); 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() { 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 traits.contains(&trait_pred.def_id()) =>
{ {
if unsize_did == trait_pred.def_id() { if unsize_did == trait_pred.def_id() {

View file

@ -226,13 +226,13 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
// could be extended easily also to the other `Predicate`. // could be extended easily also to the other `Predicate`.
let predicate_matches_closure = |p: Predicate<'tcx>| { let predicate_matches_closure = |p: Predicate<'tcx>| {
let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env); let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env);
let predicate = predicate.bound_atom(); let predicate = predicate.kind();
let p = p.bound_atom(); let p = p.kind();
match (predicate.skip_binder(), p.skip_binder()) { 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() 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() relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
} }
_ => predicate == p, _ => predicate == p,

View file

@ -542,7 +542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.register_predicate(traits::Obligation::new( self.register_predicate(traits::Obligation::new(
cause, cause,
self.param_env, self.param_env,
ty::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() .pending_obligations()
.into_iter() .into_iter()
.filter_map(move |obligation| { .filter_map(move |obligation| {
let bound_predicate = obligation.predicate.bound_atom(); let bound_predicate = obligation.predicate.kind();
match bound_predicate.skip_binder() { 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)) 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)) Some((bound_predicate.rebind(data).to_poly_trait_ref(), obligation))
} }
ty::PredicateAtom::Subtype(..) => None, ty::PredicateKind::Subtype(..) => None,
ty::PredicateAtom::RegionOutlives(..) => None, ty::PredicateKind::RegionOutlives(..) => None,
ty::PredicateAtom::TypeOutlives(..) => None, ty::PredicateKind::TypeOutlives(..) => None,
ty::PredicateAtom::WellFormed(..) => None, ty::PredicateKind::WellFormed(..) => None,
ty::PredicateAtom::ObjectSafe(..) => None, ty::PredicateKind::ObjectSafe(..) => None,
ty::PredicateAtom::ConstEvaluatable(..) => None, ty::PredicateKind::ConstEvaluatable(..) => None,
ty::PredicateAtom::ConstEquate(..) => None, ty::PredicateKind::ConstEquate(..) => None,
// N.B., this predicate is created by breaking down a // N.B., this predicate is created by breaking down a
// `ClosureType: FnFoo()` predicate, where // `ClosureType: FnFoo()` predicate, where
// `ClosureType` represents some `Closure`. It can't // `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 // this closure yet; this is exactly why the other
// code is looking for a self type of a unresolved // code is looking for a self type of a unresolved
// inference variable. // inference variable.
ty::PredicateAtom::ClosureKind(..) => None, ty::PredicateKind::ClosureKind(..) => None,
ty::PredicateAtom::TypeWellFormedFromEnv(..) => None, ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
} }
}) })
.filter(move |(tr, _)| self.self_type_matches_expected_vid(*tr, ty_var_root)) .filter(move |(tr, _)| self.self_type_matches_expected_vid(*tr, ty_var_root))

View file

@ -923,8 +923,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
continue; continue;
} }
if let ty::PredicateAtom::Trait(predicate, _) = if let ty::PredicateKind::Trait(predicate, _) =
error.obligation.predicate.skip_binders() error.obligation.predicate.kind().skip_binder()
{ {
// Collect the argument position for all arguments that could have caused this // Collect the argument position for all arguments that could have caused this
// `FulfillmentError`. // `FulfillmentError`.
@ -974,8 +974,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let hir::ExprKind::Path(qpath) = &path.kind { if let hir::ExprKind::Path(qpath) = &path.kind {
if let hir::QPath::Resolved(_, path) = &qpath { if let hir::QPath::Resolved(_, path) = &qpath {
for error in errors { for error in errors {
if let ty::PredicateAtom::Trait(predicate, _) = if let ty::PredicateKind::Trait(predicate, _) =
error.obligation.predicate.skip_binders() error.obligation.predicate.kind().skip_binder()
{ {
// If any of the type arguments in this path segment caused the // If any of the type arguments in this path segment caused the
// `FullfillmentError`, point at its span (#61860). // `FullfillmentError`, point at its span (#61860).

View file

@ -194,8 +194,8 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
parent: None, parent: None,
predicates: tcx.arena.alloc_from_iter( predicates: tcx.arena.alloc_from_iter(
self.param_env.caller_bounds().iter().filter_map(|predicate| { self.param_env.caller_bounds().iter().filter_map(|predicate| {
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(data, _) if data.self_ty().is_param(index) => { ty::PredicateKind::Trait(data, _) if data.self_ty().is_param(index) => {
// HACK(eddyb) should get the original `Span`. // HACK(eddyb) should get the original `Span`.
let span = tcx.def_span(def_id); let span = tcx.def_span(def_id);
Some((predicate, span)) Some((predicate, span))

View file

@ -478,8 +478,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied()) traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
// We don't care about regions here. // We don't care about regions here.
.filter_map(|obligation| match obligation.predicate.skip_binders() { .filter_map(|obligation| match obligation.predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => { ty::PredicateKind::Trait(trait_pred, _) if trait_pred.def_id() == sized_def_id => {
let span = predicates let span = predicates
.predicates .predicates
.iter() .iter()

View file

@ -399,7 +399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
obligations.push(traits::Obligation::new( obligations.push(traits::Obligation::new(
cause, cause,
self.param_env, self.param_env,
ty::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 }; let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };

View file

@ -795,9 +795,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
debug!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty); debug!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty);
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| { 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() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(trait_predicate, _) => { ty::PredicateKind::Trait(trait_predicate, _) => {
match *trait_predicate.trait_ref.self_ty().kind() { match *trait_predicate.trait_ref.self_ty().kind() {
ty::Param(p) if p == param_ty => { ty::Param(p) if p == param_ty => {
Some(bound_predicate.rebind(trait_predicate.trait_ref)) Some(bound_predicate.rebind(trait_predicate.trait_ref))
@ -805,16 +805,16 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
_ => None, _ => None,
} }
} }
ty::PredicateAtom::Subtype(..) ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::Projection(..) | ty::PredicateKind::Projection(..)
| ty::PredicateAtom::RegionOutlives(..) | ty::PredicateKind::RegionOutlives(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::TypeOutlives(..) | ty::PredicateKind::TypeOutlives(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None, | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
} }
}); });

View file

@ -582,8 +582,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut collect_type_param_suggestions = let mut collect_type_param_suggestions =
|self_ty: Ty<'tcx>, parent_pred: &ty::Predicate<'tcx>, obligation: &str| { |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. // We don't care about regions here, so it's fine to skip the binder here.
if let (ty::Param(_), ty::PredicateAtom::Trait(p, _)) = if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) =
(self_ty.kind(), parent_pred.skip_binders()) (self_ty.kind(), parent_pred.kind().skip_binder())
{ {
if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() { if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() {
let node = def.did.as_local().map(|def_id| { 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 mut format_pred = |pred: ty::Predicate<'tcx>| {
let bound_predicate = pred.bound_atom(); let bound_predicate = pred.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Projection(pred) => { ty::PredicateKind::Projection(pred) => {
let pred = bound_predicate.rebind(pred); let pred = bound_predicate.rebind(pred);
// `<Foo as Iterator>::Item = String`. // `<Foo as Iterator>::Item = String`.
let trait_ref = let trait_ref =
@ -658,7 +658,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
bound_span_label(trait_ref.self_ty(), &obligation, &quiet); bound_span_label(trait_ref.self_ty(), &obligation, &quiet);
Some((obligation, trait_ref.self_ty())) 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 p = poly_trait_ref.trait_ref;
let self_ty = p.self_ty(); let self_ty = p.self_ty();
let path = p.print_only_trait_path(); 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 // implementing a trait would be legal but is rejected
// here). // here).
unsatisfied_predicates.iter().all(|(p, _)| { 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 // Hide traits if they are present in predicates as they can be fixed without
// having to implement them. // having to implement them.
ty::PredicateAtom::Trait(t, _) => t.def_id() == info.def_id, ty::PredicateKind::Trait(t, _) => t.def_id() == info.def_id,
ty::PredicateAtom::Projection(p) => { ty::PredicateKind::Projection(p) => {
p.projection_ty.item_def_id == info.def_id p.projection_ty.item_def_id == info.def_id
} }
_ => false, _ => false,

View file

@ -864,9 +864,9 @@ fn bounds_from_generic_predicates<'tcx>(
let mut projections = vec![]; let mut projections = vec![];
for (predicate, _) in predicates.predicates { for (predicate, _) in predicates.predicates {
debug!("predicate {:?}", predicate); debug!("predicate {:?}", predicate);
let bound_predicate = predicate.bound_atom(); let bound_predicate = predicate.kind();
match bound_predicate.skip_binder() { 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 entry = types.entry(trait_predicate.self_ty()).or_default();
let def_id = trait_predicate.def_id(); let def_id = trait_predicate.def_id();
if Some(def_id) != tcx.lang_items().sized_trait() { 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()); entry.push(trait_predicate.def_id());
} }
} }
ty::PredicateAtom::Projection(projection_pred) => { ty::PredicateKind::Projection(projection_pred) => {
projections.push(bound_predicate.rebind(projection_pred)); projections.push(bound_predicate.rebind(projection_pred));
} }
_ => {} _ => {}

View file

@ -532,7 +532,7 @@ fn check_type_defn<'tcx, F>(
fcx.register_predicate(traits::Obligation::new( fcx.register_predicate(traits::Obligation::new(
cause, cause,
fcx.param_env, fcx.param_env,
ty::PredicateAtom::ConstEvaluatable( ty::PredicateKind::ConstEvaluatable(
ty::WithOptConstParam::unknown(discr_def_id.to_def_id()), ty::WithOptConstParam::unknown(discr_def_id.to_def_id()),
discr_substs, discr_substs,
) )

View file

@ -562,8 +562,8 @@ fn type_param_predicates(
let extra_predicates = extend.into_iter().chain( let extra_predicates = extend.into_iter().chain(
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true)) icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
.into_iter() .into_iter()
.filter(|(predicate, _)| match predicate.skip_binders() { .filter(|(predicate, _)| match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(data, _) => data.self_ty().is_param(index), ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index),
_ => false, _ => false,
}), }),
); );
@ -1027,7 +1027,7 @@ fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredi
// which will, in turn, reach indirect supertraits. // which will, in turn, reach indirect supertraits.
for &(pred, span) in superbounds { for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred); 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()); 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 { } else {
let span = bound_pred.bounded_ty.span; let span = bound_pred.bounded_ty.span;
let re_root_empty = tcx.lifetimes.re_root_empty; 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), ty::OutlivesPredicate(ty, re_root_empty),
)); ));
predicates.insert((predicate.to_predicate(tcx), span)); 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) => { hir::GenericBound::Outlives(lifetime) => {
let region = AstConv::ast_region_to_region(&icx, lifetime, None); let region = AstConv::ast_region_to_region(&icx, lifetime, None);
predicates.insert(( predicates.insert((
ty::Binder::bind(ty::PredicateAtom::TypeOutlives( ty::Binder::bind(ty::PredicateKind::TypeOutlives(
ty::OutlivesPredicate(ty, region), ty::OutlivesPredicate(ty, region),
)) ))
.to_predicate(tcx), .to_predicate(tcx),
@ -2010,7 +2010,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
} }
_ => bug!(), _ => bug!(),
}; };
let pred = ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r1, r2)) let pred = ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
.to_predicate(icx.tcx); .to_predicate(icx.tcx);
(pred, span) (pred, span)
@ -2075,7 +2075,7 @@ fn const_evaluatable_predicates_of<'tcx>(
if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val { if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val {
let span = self.tcx.hir().span(c.hir_id); let span = self.tcx.hir().span(c.hir_id);
self.preds.insert(( self.preds.insert((
ty::PredicateAtom::ConstEvaluatable(def, substs).to_predicate(self.tcx), ty::PredicateKind::ConstEvaluatable(def, substs).to_predicate(self.tcx),
span, span,
)); ));
} }
@ -2094,7 +2094,7 @@ fn const_evaluatable_predicates_of<'tcx>(
fn visit_const(&mut self, ct: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_const(&mut self, ct: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val { if let ty::ConstKind::Unevaluated(def, substs, None) = ct.val {
self.preds.insert(( self.preds.insert((
ty::PredicateAtom::ConstEvaluatable(def, substs).to_predicate(self.tcx), ty::PredicateKind::ConstEvaluatable(def, substs).to_predicate(self.tcx),
self.span, self.span,
)); ));
} }
@ -2180,12 +2180,12 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
.predicates .predicates
.iter() .iter()
.copied() .copied()
.filter(|(pred, _)| match pred.skip_binders() { .filter(|(pred, _)| match pred.kind().skip_binder() {
ty::PredicateAtom::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()), ty::PredicateKind::Trait(tr, _) => !is_assoc_item_ty(tr.self_ty()),
ty::PredicateAtom::Projection(proj) => { ty::PredicateKind::Projection(proj) => {
!is_assoc_item_ty(proj.projection_ty.self_ty()) !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, _ => true,
}) })
.collect(); .collect();
@ -2214,7 +2214,8 @@ fn projection_ty_from_predicates(
let (ty_def_id, item_def_id) = key; let (ty_def_id, item_def_id) = key;
let mut projection_ty = None; let mut projection_ty = None;
for (predicate, _) in tcx.predicates_of(ty_def_id).predicates { 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 { if item_def_id == projection_predicate.projection_ty.item_def_id {
projection_ty = Some(projection_predicate.projection_ty); projection_ty = Some(projection_predicate.projection_ty);
break; break;
@ -2261,7 +2262,7 @@ fn predicates_from_bound<'tcx>(
} }
hir::GenericBound::Outlives(ref lifetime) => { hir::GenericBound::Outlives(ref lifetime) => {
let region = astconv.ast_region_to_region(lifetime, None); 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()); .to_predicate(astconv.tcx());
vec![(pred, lifetime.span)] vec![(pred, lifetime.span)]
} }

View file

@ -36,12 +36,13 @@ fn associated_type_bounds<'tcx>(
let trait_def_id = tcx.associated_item(assoc_item_def_id).container.id(); 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 trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id.expect_local());
let bounds_from_parent = let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
trait_predicates.predicates.iter().copied().filter(|(pred, _)| match pred.skip_binders() { match pred.kind().skip_binder() {
ty::PredicateAtom::Trait(tr, _) => tr.self_ty() == item_ty, ty::PredicateKind::Trait(tr, _) => tr.self_ty() == item_ty,
ty::PredicateAtom::Projection(proj) => proj.projection_ty.self_ty() == item_ty, ty::PredicateKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
ty::PredicateAtom::TypeOutlives(outlives) => outlives.0 == item_ty, ty::PredicateKind::TypeOutlives(outlives) => outlives.0 == item_ty,
_ => false, _ => false,
}
}); });
let all_bounds = tcx let all_bounds = tcx

View file

@ -183,7 +183,8 @@ pub fn setup_constraining_predicates<'tcx>(
for j in i..predicates.len() { for j in i..predicates.len() {
// Note that we don't have to care about binders here, // Note that we don't have to care about binders here,
// as the impl trait ref never contains any late-bound regions. // 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 // Special case: watch out for some kind of sneaky attempt
// to project out an associated type defined by this very // to project out an associated type defined by this very
// trait. // trait.

View file

@ -198,7 +198,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
// the functions in `cgp` add the constrained parameters to a list of // the functions in `cgp` add the constrained parameters to a list of
// unconstrained parameters. // unconstrained parameters.
for (predicate, _) in impl_generic_predicates.predicates.iter() { 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 projection_ty = proj.projection_ty;
let projected_ty = proj.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) { fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>, span: Span) {
debug!("can_specialize_on(predicate = {:?})", predicate); 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 // Global predicates are either always true or always false, so we
// are fine to specialize on. // are fine to specialize on.
_ if predicate.is_global() => (), _ if predicate.is_global() => (),
// We allow specializing on explicitly marked traits with no associated // We allow specializing on explicitly marked traits with no associated
// items. // items.
ty::PredicateAtom::Trait(pred, hir::Constness::NotConst) => { ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
if !matches!( if !matches!(
trait_predicate_kind(tcx, predicate), trait_predicate_kind(tcx, predicate),
Some(TraitSpecializationKind::Marker) Some(TraitSpecializationKind::Marker)
@ -393,20 +393,20 @@ fn trait_predicate_kind<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
predicate: ty::Predicate<'tcx>, predicate: ty::Predicate<'tcx>,
) -> Option<TraitSpecializationKind> { ) -> Option<TraitSpecializationKind> {
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::Trait(pred, hir::Constness::NotConst) => { ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
Some(tcx.trait_def(pred.def_id()).specialization_kind) Some(tcx.trait_def(pred.def_id()).specialization_kind)
} }
ty::PredicateAtom::Trait(_, hir::Constness::Const) ty::PredicateKind::Trait(_, hir::Constness::Const)
| ty::PredicateAtom::RegionOutlives(_) | ty::PredicateKind::RegionOutlives(_)
| ty::PredicateAtom::TypeOutlives(_) | ty::PredicateKind::TypeOutlives(_)
| ty::PredicateAtom::Projection(_) | ty::PredicateKind::Projection(_)
| ty::PredicateAtom::WellFormed(_) | ty::PredicateKind::WellFormed(_)
| ty::PredicateAtom::Subtype(_) | ty::PredicateKind::Subtype(_)
| ty::PredicateAtom::ObjectSafe(_) | ty::PredicateKind::ObjectSafe(_)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => None, | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
} }
} }

View file

@ -29,8 +29,8 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
// process predicates and convert to `RequiredPredicates` entry, see below // process predicates and convert to `RequiredPredicates` entry, see below
for &(predicate, span) in predicates.predicates { for &(predicate, span) in predicates.predicates {
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => { ty::PredicateKind::TypeOutlives(OutlivesPredicate(ref ty, ref reg)) => {
insert_outlives_predicate( insert_outlives_predicate(
tcx, tcx,
(*ty).into(), (*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( insert_outlives_predicate(
tcx, tcx,
(*reg1).into(), (*reg1).into(),
@ -50,15 +50,15 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
) )
} }
ty::PredicateAtom::Trait(..) ty::PredicateKind::Trait(..)
| ty::PredicateAtom::Projection(..) | ty::PredicateKind::Projection(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::Subtype(..) | ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => (), | ty::PredicateKind::TypeWellFormedFromEnv(..) => (),
} }
} }

View file

@ -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) { if tcx.has_attr(item_def_id, sym::rustc_outlives) {
let mut pred: Vec<String> = predicates let mut pred: Vec<String> = predicates
.iter() .iter()
.map(|(out_pred, _)| match out_pred.bound_atom().skip_binder() { .map(|(out_pred, _)| match out_pred.kind().skip_binder() {
ty::PredicateAtom::RegionOutlives(p) => p.to_string(), ty::PredicateKind::RegionOutlives(p) => p.to_string(),
ty::PredicateAtom::TypeOutlives(p) => p.to_string(), ty::PredicateKind::TypeOutlives(p) => p.to_string(),
err => bug!("unexpected predicate {:?}", err), err => bug!("unexpected predicate {:?}", err),
}) })
.collect(); .collect();
@ -85,12 +85,12 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
|(ty::OutlivesPredicate(kind1, region2), &span)| { |(ty::OutlivesPredicate(kind1, region2), &span)| {
match kind1.unpack() { match kind1.unpack() {
GenericArgKind::Type(ty1) => Some(( GenericArgKind::Type(ty1) => Some((
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty1, region2)) ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty1, region2))
.to_predicate(tcx), .to_predicate(tcx),
span, span,
)), )),
GenericArgKind::Lifetime(region1) => Some(( GenericArgKind::Lifetime(region1) => Some((
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate( ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
region1, region2, region1, region2,
)) ))
.to_predicate(tcx), .to_predicate(tcx),

View file

@ -313,12 +313,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
pred: ty::Predicate<'tcx>, pred: ty::Predicate<'tcx>,
) -> FxHashSet<GenericParamDef> { ) -> FxHashSet<GenericParamDef> {
let bound_predicate = pred.bound_atom(); let bound_predicate = pred.kind();
let regions = match bound_predicate.skip_binder() { 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)) 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)) tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_proj_pred))
} }
_ => return FxHashSet::default(), _ => return FxHashSet::default(),
@ -463,8 +463,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
.iter() .iter()
.filter(|p| { .filter(|p| {
!orig_bounds.contains(p) !orig_bounds.contains(p)
|| match p.skip_binders() { || match p.kind().skip_binder() {
ty::PredicateAtom::Trait(pred, _) => pred.def_id() == sized_trait, ty::PredicateKind::Trait(pred, _) => pred.def_id() == sized_trait,
_ => false, _ => false,
} }
}) })

View file

@ -465,20 +465,20 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> { impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> { fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
let bound_predicate = self.bound_atom(); let bound_predicate = self.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)), ty::PredicateKind::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)),
ty::PredicateAtom::RegionOutlives(pred) => pred.clean(cx), ty::PredicateKind::RegionOutlives(pred) => pred.clean(cx),
ty::PredicateAtom::TypeOutlives(pred) => pred.clean(cx), ty::PredicateKind::TypeOutlives(pred) => pred.clean(cx),
ty::PredicateAtom::Projection(pred) => Some(pred.clean(cx)), ty::PredicateKind::Projection(pred) => Some(pred.clean(cx)),
ty::PredicateAtom::Subtype(..) ty::PredicateKind::Subtype(..)
| ty::PredicateAtom::WellFormed(..) | ty::PredicateKind::WellFormed(..)
| ty::PredicateAtom::ObjectSafe(..) | ty::PredicateKind::ObjectSafe(..)
| ty::PredicateAtom::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => panic!("not user writable"), | 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, _)| { .flat_map(|(p, _)| {
let mut projection = None; let mut projection = None;
let param_idx = (|| { let param_idx = (|| {
let bound_p = p.bound_atom(); let bound_p = p.kind();
match bound_p.skip_binder() { match bound_p.skip_binder() {
ty::PredicateAtom::Trait(pred, _constness) => { ty::PredicateKind::Trait(pred, _constness) => {
if let ty::Param(param) = pred.self_ty().kind() { if let ty::Param(param) = pred.self_ty().kind() {
return Some(param.index); 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() { if let ty::Param(param) = ty.kind() {
return Some(param.index); return Some(param.index);
} }
} }
ty::PredicateAtom::Projection(p) => { ty::PredicateKind::Projection(p) => {
if let ty::Param(param) = p.projection_ty.self_ty().kind() { if let ty::Param(param) = p.projection_ty.self_ty().kind() {
projection = Some(bound_p.rebind(p)); projection = Some(bound_p.rebind(p));
return Some(param.index); return Some(param.index);
@ -1686,12 +1686,12 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
.filter_map(|bound| { .filter_map(|bound| {
// Note: The substs of opaque types can contain unbound variables, // Note: The substs of opaque types can contain unbound variables,
// meaning that we have to use `ignore_quantifiers_with_unbound_vars` here. // 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() { let trait_ref = match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(tr, _constness) => { ty::PredicateKind::Trait(tr, _constness) => {
bound_predicate.rebind(tr.trait_ref) 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) { if let Some(r) = reg.clean(cx) {
regions.push(GenericBound::Outlives(r)); regions.push(GenericBound::Outlives(r));
} }
@ -1710,8 +1710,8 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
let bounds: Vec<_> = bounds let bounds: Vec<_> = bounds
.iter() .iter()
.filter_map(|bound| { .filter_map(|bound| {
if let ty::PredicateAtom::Projection(proj) = if let ty::PredicateKind::Projection(proj) =
bound.bound_atom().skip_binder() bound.kind().skip_binder()
{ {
if proj.projection_ty.trait_ref(cx.tcx) if proj.projection_ty.trait_ref(cx.tcx)
== trait_ref.skip_binder() == trait_ref.skip_binder()

View file

@ -129,7 +129,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
.predicates .predicates
.iter() .iter()
.filter_map(|(pred, _)| { .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 } if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
} else { } else {
None None

View file

@ -4,7 +4,7 @@ use rustc_hir::{Body, FnDecl, HirId};
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::subst::Subst; 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_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{sym, Span}; use rustc_span::{sym, Span};
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt; use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
&obligation, &obligation,
); );
if let Trait(trait_pred, _) = if let Trait(trait_pred, _) =
obligation.predicate.skip_binders() obligation.predicate.kind().skip_binder()
{ {
db.note(&format!( db.note(&format!(
"`{}` doesn't implement `{}`", "`{}` doesn't implement `{}`",

View file

@ -1697,7 +1697,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
if let ty::Opaque(def_id, _) = *ret_ty.kind() { if let ty::Opaque(def_id, _) = *ret_ty.kind() {
// one of the associated types must be Self // one of the associated types must be Self
for &(predicate, _span) in cx.tcx.explicit_item_bounds(def_id) { 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 // walk the associated type and check for Self
if contains_ty(projection_predicate.ty, self_ty) { if contains_ty(projection_predicate.ty, self_ty) {
return; return;

View file

@ -115,13 +115,10 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
.filter(|p| !p.is_global()) .filter(|p| !p.is_global())
.filter_map(|obligation| { .filter_map(|obligation| {
// Note that we do not want to deal with qualified predicates here. // Note that we do not want to deal with qualified predicates here.
match obligation.predicate.bound_atom().skip_binder() { match obligation.predicate.kind().no_bound_vars() {
ty::PredicateAtom::Trait(pred, _) if !pred.has_escaping_bound_vars() => { Some(ty::PredicateKind::Trait(pred, _)) if pred.def_id() != sized_trait => {
if pred.def_id() == sized_trait {
return None;
}
Some(pred) Some(pred)
} },
_ => None, _ => None,
} }
}) })

View file

@ -4,7 +4,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, StmtKind}; use rustc_hir::{Expr, ExprKind, StmtKind};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty; 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_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{BytePos, Span}; use rustc_span::{BytePos, Span};
@ -42,7 +42,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
let mut preds = Vec::new(); let mut preds = Vec::new();
for (pred, _) in generics.predicates { for (pred, _) in generics.predicates {
if_chain! { 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)); let trait_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(poly_trait_pred));
if let Some(trait_def_id) = trait_id; if let Some(trait_def_id) = trait_id;
if trait_def_id == trait_pred.trait_ref.def_id; if trait_def_id == trait_pred.trait_ref.def_id;
@ -60,7 +60,7 @@ fn get_projection_pred<'tcx>(
pred: TraitPredicate<'tcx>, pred: TraitPredicate<'tcx>,
) -> Option<ProjectionPredicate<'tcx>> { ) -> Option<ProjectionPredicate<'tcx>> {
generics.predicates.iter().find_map(|(proj_pred, _)| { 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)); let projection_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(proj_pred));
if projection_pred.projection_ty.substs == pred.trait_ref.substs { if projection_pred.projection_ty.substs == pred.trait_ref.substs {
return Some(projection_pred); return Some(projection_pred);

View file

@ -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::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
ty::Opaque(ref def_id, _) => { ty::Opaque(ref def_id, _) => {
for (predicate, _) in cx.tcx.explicit_item_bounds(*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() { if must_use_attr(&cx.tcx.get_attrs(trait_predicate.trait_ref.def_id)).is_some() {
return true; return true;
} }

View file

@ -19,18 +19,18 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>) -> McfResult {
loop { loop {
let predicates = tcx.predicates_of(current); let predicates = tcx.predicates_of(current);
for (predicate, _) in predicates.predicates { for (predicate, _) in predicates.predicates {
match predicate.skip_binders() { match predicate.kind().skip_binder() {
ty::PredicateAtom::RegionOutlives(_) ty::PredicateKind::RegionOutlives(_)
| ty::PredicateAtom::TypeOutlives(_) | ty::PredicateKind::TypeOutlives(_)
| ty::PredicateAtom::WellFormed(_) | ty::PredicateKind::WellFormed(_)
| ty::PredicateAtom::Projection(_) | ty::PredicateKind::Projection(_)
| ty::PredicateAtom::ConstEvaluatable(..) | ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateAtom::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => continue, | ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
ty::PredicateAtom::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate), ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
ty::PredicateAtom::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate), ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
ty::PredicateAtom::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate), ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
ty::PredicateAtom::Trait(pred, _) => { ty::PredicateKind::Trait(pred, _) => {
if Some(pred.def_id()) == tcx.lang_items().sized_trait() { if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
continue; continue;
} }