1
Fork 0

rename Predicate to PredicateKind, introduce alias

This commit is contained in:
Bastian Kauschke 2020-05-11 21:09:57 +02:00
parent f182c4af8a
commit cad8fe90fd
53 changed files with 406 additions and 383 deletions

View file

@ -532,12 +532,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
cause.clone(),
param_env,
match k1.unpack() {
GenericArgKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
GenericArgKind::Lifetime(r1) => ty::PredicateKind::RegionOutlives(
ty::Binder::bind(ty::OutlivesPredicate(r1, r2)),
),
GenericArgKind::Type(t1) => {
ty::Predicate::TypeOutlives(ty::Binder::bind(ty::OutlivesPredicate(t1, r2)))
}
GenericArgKind::Type(t1) => ty::PredicateKind::TypeOutlives(ty::Binder::bind(
ty::OutlivesPredicate(t1, r2),
)),
GenericArgKind::Const(..) => {
// Consts cannot outlive one another, so we don't expect to
// ecounter this branch.
@ -664,7 +664,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
self.obligations.push(Obligation {
cause: self.cause.clone(),
param_env: self.param_env,
predicate: ty::Predicate::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
predicate: ty::PredicateKind::RegionOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
sup, sub,
))),
recursion_depth: 0,

View file

@ -307,7 +307,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.obligations.push(Obligation::new(
self.trace.cause.clone(),
self.param_env,
ty::Predicate::WellFormed(b_ty),
ty::PredicateKind::WellFormed(b_ty),
));
}

View file

@ -12,16 +12,16 @@ pub fn explicit_outlives_bounds<'tcx>(
) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
debug!("explicit_outlives_bounds()");
param_env.caller_bounds.into_iter().filter_map(move |predicate| match predicate {
ty::Predicate::Projection(..)
| ty::Predicate::Trait(..)
| ty::Predicate::Subtype(..)
| ty::Predicate::WellFormed(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::TypeOutlives(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => None,
ty::Predicate::RegionOutlives(ref data) => data
ty::PredicateKind::Projection(..)
| ty::PredicateKind::Trait(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::TypeOutlives(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => None,
ty::PredicateKind::RegionOutlives(ref data) => data
.no_bound_vars()
.map(|ty::OutlivesPredicate(r_a, r_b)| 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.trace.cause.clone(),
self.fields.param_env,
ty::Predicate::Subtype(ty::Binder::dummy(ty::SubtypePredicate {
ty::PredicateKind::Subtype(ty::Binder::dummy(ty::SubtypePredicate {
a_is_expected: self.a_is_expected,
a,
b,

View file

@ -11,39 +11,39 @@ pub fn anonymize_predicate<'tcx>(
pred: &ty::Predicate<'tcx>,
) -> ty::Predicate<'tcx> {
match *pred {
ty::Predicate::Trait(ref data, constness) => {
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data), constness)
ty::PredicateKind::Trait(ref data, constness) => {
ty::PredicateKind::Trait(tcx.anonymize_late_bound_regions(data), constness)
}
ty::Predicate::RegionOutlives(ref data) => {
ty::Predicate::RegionOutlives(tcx.anonymize_late_bound_regions(data))
ty::PredicateKind::RegionOutlives(ref data) => {
ty::PredicateKind::RegionOutlives(tcx.anonymize_late_bound_regions(data))
}
ty::Predicate::TypeOutlives(ref data) => {
ty::Predicate::TypeOutlives(tcx.anonymize_late_bound_regions(data))
ty::PredicateKind::TypeOutlives(ref data) => {
ty::PredicateKind::TypeOutlives(tcx.anonymize_late_bound_regions(data))
}
ty::Predicate::Projection(ref data) => {
ty::Predicate::Projection(tcx.anonymize_late_bound_regions(data))
ty::PredicateKind::Projection(ref data) => {
ty::PredicateKind::Projection(tcx.anonymize_late_bound_regions(data))
}
ty::Predicate::WellFormed(data) => ty::Predicate::WellFormed(data),
ty::PredicateKind::WellFormed(data) => ty::PredicateKind::WellFormed(data),
ty::Predicate::ObjectSafe(data) => ty::Predicate::ObjectSafe(data),
ty::PredicateKind::ObjectSafe(data) => ty::PredicateKind::ObjectSafe(data),
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind)
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind)
}
ty::Predicate::Subtype(ref data) => {
ty::Predicate::Subtype(tcx.anonymize_late_bound_regions(data))
ty::PredicateKind::Subtype(ref data) => {
ty::PredicateKind::Subtype(tcx.anonymize_late_bound_regions(data))
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
ty::Predicate::ConstEvaluatable(def_id, substs)
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
ty::PredicateKind::ConstEvaluatable(def_id, substs)
}
ty::Predicate::ConstEquate(c1, c2) => ty::Predicate::ConstEquate(c1, c2),
ty::PredicateKind::ConstEquate(c1, c2) => ty::Predicate::ConstEquate(c1, c2),
}
}
@ -146,7 +146,7 @@ impl Elaborator<'tcx> {
fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) {
let tcx = self.visited.tcx;
match obligation.predicate {
ty::Predicate::Trait(ref data, _) => {
ty::PredicateKind::Trait(ref data, _) => {
// Get predicates declared on the trait.
let predicates = tcx.super_predicates_of(data.def_id());
@ -167,36 +167,36 @@ impl Elaborator<'tcx> {
self.stack.extend(obligations);
}
ty::Predicate::WellFormed(..) => {
ty::PredicateKind::WellFormed(..) => {
// Currently, we do not elaborate WF predicates,
// although we easily could.
}
ty::Predicate::ObjectSafe(..) => {
ty::PredicateKind::ObjectSafe(..) => {
// Currently, we do not elaborate object-safe
// predicates.
}
ty::Predicate::Subtype(..) => {
ty::PredicateKind::Subtype(..) => {
// Currently, we do not "elaborate" predicates like `X <: Y`,
// though conceivably we might.
}
ty::Predicate::Projection(..) => {
ty::PredicateKind::Projection(..) => {
// Nothing to elaborate in a projection predicate.
}
ty::Predicate::ClosureKind(..) => {
ty::PredicateKind::ClosureKind(..) => {
// Nothing to elaborate when waiting for a closure's kind to be inferred.
}
ty::Predicate::ConstEvaluatable(..) => {
ty::PredicateKind::ConstEvaluatable(..) => {
// Currently, we do not elaborate const-evaluatable
// predicates.
}
ty::Predicate::ConstEquate(..) => {
ty::PredicateKind::ConstEquate(..) => {
// Currently, we do not elaborate const-equate
// predicates.
}
ty::Predicate::RegionOutlives(..) => {
ty::PredicateKind::RegionOutlives(..) => {
// Nothing to elaborate from `'a: 'b`.
}
ty::Predicate::TypeOutlives(ref data) => {
ty::PredicateKind::TypeOutlives(ref data) => {
// We know that `T: 'a` for some type `T`. We can
// often elaborate this. For example, if we know that
// `[U]: 'a`, that implies that `U: 'a`. Similarly, if
@ -228,7 +228,7 @@ impl Elaborator<'tcx> {
if r.is_late_bound() {
None
} else {
Some(ty::Predicate::RegionOutlives(ty::Binder::dummy(
Some(ty::PredicateKind::RegionOutlives(ty::Binder::dummy(
ty::OutlivesPredicate(r, r_min),
)))
}
@ -236,7 +236,7 @@ impl Elaborator<'tcx> {
Component::Param(p) => {
let ty = tcx.mk_ty_param(p.index, p.name);
Some(ty::Predicate::TypeOutlives(ty::Binder::dummy(
Some(ty::PredicateKind::TypeOutlives(ty::Binder::dummy(
ty::OutlivesPredicate(ty, r_min),
)))
}
@ -317,7 +317,7 @@ impl<'tcx, I: Iterator<Item = PredicateObligation<'tcx>>> Iterator for FilterToT
fn next(&mut self) -> Option<ty::PolyTraitRef<'tcx>> {
while let Some(obligation) = self.base_iterator.next() {
if let ty::Predicate::Trait(data, _) = obligation.predicate {
if let ty::PredicateKind::Trait(data, _) = obligation.predicate {
return Some(data.to_poly_trait_ref());
}
}

View file

@ -1202,7 +1202,7 @@ declare_lint_pass!(
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'tcx>) {
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::Predicate::*;
use rustc_middle::ty::PredicateKind::*;
if cx.tcx.features().trivial_bounds {
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
@ -1498,7 +1498,7 @@ impl ExplicitOutlivesRequirements {
inferred_outlives
.iter()
.filter_map(|(pred, _)| match pred {
ty::Predicate::RegionOutlives(outlives) => {
ty::PredicateKind::RegionOutlives(outlives) => {
let outlives = outlives.skip_binder();
match outlives.0 {
ty::ReEarlyBound(ebr) if ebr.index == index => Some(outlives.1),
@ -1517,7 +1517,7 @@ impl ExplicitOutlivesRequirements {
inferred_outlives
.iter()
.filter_map(|(pred, _)| match pred {
ty::Predicate::TypeOutlives(outlives) => {
ty::PredicateKind::TypeOutlives(outlives) => {
let outlives = outlives.skip_binder();
outlives.0.is_param(index).then_some(outlives.1)
}

View file

@ -146,7 +146,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
ty::Opaque(def, _) => {
let mut has_emitted = false;
for (predicate, _) in cx.tcx.predicates_of(def).predicates {
if let ty::Predicate::Trait(ref poly_trait_predicate, _) = predicate {
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) = predicate {
let trait_ref = poly_trait_predicate.skip_binder().trait_ref;
let def_id = trait_ref.def_id;
let descr_pre =

View file

@ -201,9 +201,9 @@ where
assert!(pos >= SHORTHAND_OFFSET);
let shorthand = pos - SHORTHAND_OFFSET;
decoder.with_position(shorthand, ty::Predicate::decode)
decoder.with_position(shorthand, ty::PredicateKind::decode)
} else {
ty::Predicate::decode(decoder)
ty::PredicateKind::decode(decoder)
}?;
Ok((predicate, Decodable::decode(decoder)?))
})

View file

@ -1016,9 +1016,11 @@ impl<'tcx> GenericPredicates<'tcx> {
}
}
pub type Predicate<'tcx> = PredicateKind<'tcx>;
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
#[derive(HashStable, TypeFoldable)]
pub enum Predicate<'tcx> {
pub enum PredicateKind<'tcx> {
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
/// the `Self` type of the trait reference and `A`, `B`, and `C`
/// would be the type parameters.
@ -1079,7 +1081,7 @@ impl<'tcx> AsRef<Predicate<'tcx>> for Predicate<'tcx> {
}
}
impl<'tcx> Predicate<'tcx> {
impl<'tcx> PredicateKind<'tcx> {
/// Performs a substitution suitable for going from a
/// poly-trait-ref to supertraits that must hold if that
/// poly-trait-ref holds. This is slightly different from a normal
@ -1152,31 +1154,31 @@ impl<'tcx> Predicate<'tcx> {
let substs = &trait_ref.skip_binder().substs;
match *self {
Predicate::Trait(ref binder, constness) => {
Predicate::Trait(binder.map_bound(|data| data.subst(tcx, substs)), constness)
PredicateKind::Trait(ref binder, constness) => {
PredicateKind::Trait(binder.map_bound(|data| data.subst(tcx, substs)), constness)
}
Predicate::Subtype(ref binder) => {
Predicate::Subtype(binder.map_bound(|data| data.subst(tcx, substs)))
PredicateKind::Subtype(ref binder) => {
PredicateKind::Subtype(binder.map_bound(|data| data.subst(tcx, substs)))
}
Predicate::RegionOutlives(ref binder) => {
Predicate::RegionOutlives(binder.map_bound(|data| data.subst(tcx, substs)))
PredicateKind::RegionOutlives(ref binder) => {
PredicateKind::RegionOutlives(binder.map_bound(|data| data.subst(tcx, substs)))
}
Predicate::TypeOutlives(ref binder) => {
Predicate::TypeOutlives(binder.map_bound(|data| data.subst(tcx, substs)))
PredicateKind::TypeOutlives(ref binder) => {
PredicateKind::TypeOutlives(binder.map_bound(|data| data.subst(tcx, substs)))
}
Predicate::Projection(ref binder) => {
Predicate::Projection(binder.map_bound(|data| data.subst(tcx, substs)))
PredicateKind::Projection(ref binder) => {
PredicateKind::Projection(binder.map_bound(|data| data.subst(tcx, substs)))
}
Predicate::WellFormed(data) => Predicate::WellFormed(data.subst(tcx, substs)),
Predicate::ObjectSafe(trait_def_id) => Predicate::ObjectSafe(trait_def_id),
Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
Predicate::ClosureKind(closure_def_id, closure_substs.subst(tcx, substs), kind)
PredicateKind::WellFormed(data) => PredicateKind::WellFormed(data.subst(tcx, substs)),
PredicateKind::ObjectSafe(trait_def_id) => PredicateKind::ObjectSafe(trait_def_id),
PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
PredicateKind::ClosureKind(closure_def_id, closure_substs.subst(tcx, substs), kind)
}
Predicate::ConstEvaluatable(def_id, const_substs) => {
Predicate::ConstEvaluatable(def_id, const_substs.subst(tcx, substs))
PredicateKind::ConstEvaluatable(def_id, const_substs) => {
PredicateKind::ConstEvaluatable(def_id, const_substs.subst(tcx, substs))
}
Predicate::ConstEquate(c1, c2) => {
Predicate::ConstEquate(c1.subst(tcx, substs), c2.subst(tcx, substs))
PredicateKind::ConstEquate(c1, c2) => {
PredicateKind::ConstEquate(c1.subst(tcx, substs), c2.subst(tcx, substs))
}
}
}
@ -1298,7 +1300,7 @@ pub trait ToPredicate<'tcx> {
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
fn to_predicate(&self) -> Predicate<'tcx> {
ty::Predicate::Trait(
ty::PredicateKind::Trait(
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value }),
self.constness,
)
@ -1307,7 +1309,7 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> {
fn to_predicate(&self) -> Predicate<'tcx> {
ty::Predicate::Trait(
ty::PredicateKind::Trait(
ty::Binder::dummy(ty::TraitPredicate { trait_ref: *self.value }),
self.constness,
)
@ -1316,62 +1318,62 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> {
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
fn to_predicate(&self) -> Predicate<'tcx> {
ty::Predicate::Trait(self.value.to_poly_trait_predicate(), self.constness)
ty::PredicateKind::Trait(self.value.to_poly_trait_predicate(), self.constness)
}
}
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&PolyTraitRef<'tcx>> {
fn to_predicate(&self) -> Predicate<'tcx> {
ty::Predicate::Trait(self.value.to_poly_trait_predicate(), self.constness)
ty::PredicateKind::Trait(self.value.to_poly_trait_predicate(), self.constness)
}
}
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> {
Predicate::RegionOutlives(*self)
PredicateKind::RegionOutlives(*self)
}
}
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> {
Predicate::TypeOutlives(*self)
PredicateKind::TypeOutlives(*self)
}
}
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> {
Predicate::Projection(*self)
PredicateKind::Projection(*self)
}
}
impl<'tcx> Predicate<'tcx> {
impl<'tcx> PredicateKind<'tcx> {
pub fn to_opt_poly_trait_ref(&self) -> Option<PolyTraitRef<'tcx>> {
match *self {
Predicate::Trait(ref t, _) => Some(t.to_poly_trait_ref()),
Predicate::Projection(..)
| Predicate::Subtype(..)
| Predicate::RegionOutlives(..)
| Predicate::WellFormed(..)
| Predicate::ObjectSafe(..)
| Predicate::ClosureKind(..)
| Predicate::TypeOutlives(..)
| Predicate::ConstEvaluatable(..)
| Predicate::ConstEquate(..) => None,
PredicateKind::Trait(ref t, _) => Some(t.to_poly_trait_ref()),
PredicateKind::Projection(..)
| PredicateKind::Subtype(..)
| PredicateKind::RegionOutlives(..)
| PredicateKind::WellFormed(..)
| PredicateKind::ObjectSafe(..)
| PredicateKind::ClosureKind(..)
| PredicateKind::TypeOutlives(..)
| PredicateKind::ConstEvaluatable(..)
| PredicateKind::ConstEquate(..) => None,
}
}
pub fn to_opt_type_outlives(&self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
match *self {
Predicate::TypeOutlives(data) => Some(data),
Predicate::Trait(..)
| Predicate::Projection(..)
| Predicate::Subtype(..)
| Predicate::RegionOutlives(..)
| Predicate::WellFormed(..)
| Predicate::ObjectSafe(..)
| Predicate::ClosureKind(..)
| Predicate::ConstEvaluatable(..)
| Predicate::ConstEquate(..) => None,
PredicateKind::TypeOutlives(data) => Some(data),
PredicateKind::Trait(..)
| PredicateKind::Projection(..)
| PredicateKind::Subtype(..)
| PredicateKind::RegionOutlives(..)
| PredicateKind::WellFormed(..)
| PredicateKind::ObjectSafe(..)
| PredicateKind::ClosureKind(..)
| PredicateKind::ConstEvaluatable(..)
| PredicateKind::ConstEquate(..) => None,
}
}
}

View file

@ -2032,28 +2032,28 @@ define_print_and_forward_display! {
ty::Predicate<'tcx> {
match *self {
ty::Predicate::Trait(ref data, constness) => {
ty::PredicateKind::Trait(ref data, constness) => {
if let hir::Constness::Const = constness {
p!(write("const "));
}
p!(print(data))
}
ty::Predicate::Subtype(ref predicate) => p!(print(predicate)),
ty::Predicate::RegionOutlives(ref predicate) => p!(print(predicate)),
ty::Predicate::TypeOutlives(ref predicate) => p!(print(predicate)),
ty::Predicate::Projection(ref predicate) => p!(print(predicate)),
ty::Predicate::WellFormed(ty) => p!(print(ty), write(" well-formed")),
ty::Predicate::ObjectSafe(trait_def_id) => {
ty::PredicateKind::Subtype(ref predicate) => p!(print(predicate)),
ty::PredicateKind::RegionOutlives(ref predicate) => p!(print(predicate)),
ty::PredicateKind::TypeOutlives(ref predicate) => p!(print(predicate)),
ty::PredicateKind::Projection(ref predicate) => p!(print(predicate)),
ty::PredicateKind::WellFormed(ty) => p!(print(ty), write(" well-formed")),
ty::PredicateKind::ObjectSafe(trait_def_id) => {
p!(write("the trait `"),
print_def_path(trait_def_id, &[]),
write("` is object-safe"))
}
ty::Predicate::ClosureKind(closure_def_id, _closure_substs, kind) => {
ty::PredicateKind::ClosureKind(closure_def_id, _closure_substs, kind) => {
p!(write("the closure `"),
print_value_path(closure_def_id, &[]),
write("` implements the trait `{}`", kind))
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
p!(write("the constant `"),
print_value_path(def_id, substs),
write("` can be evaluated"))

View file

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

View file

@ -615,7 +615,7 @@ impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
Binder(tr).with_self_ty(tcx, self_ty).without_const().to_predicate()
}
ExistentialPredicate::Projection(p) => {
ty::Predicate::Projection(Binder(p.with_self_ty(tcx, self_ty)))
ty::PredicateKind::Projection(Binder(p.with_self_ty(tcx, self_ty)))
}
ExistentialPredicate::AutoTrait(did) => {
let trait_ref =

View file

@ -576,7 +576,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let mut found = false;
for predicate in bounds.predicates {
if let ty::Predicate::TypeOutlives(binder) = predicate {
if let ty::PredicateKind::TypeOutlives(binder) = predicate {
if let ty::OutlivesPredicate(_, ty::RegionKind::ReStatic) =
binder.skip_binder()
{

View file

@ -1016,7 +1016,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
self.prove_predicate(
ty::Predicate::WellFormed(inferred_ty),
ty::PredicateKind::WellFormed(inferred_ty),
Locations::All(span),
ConstraintCategory::TypeAnnotation,
);
@ -1268,7 +1268,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
obligations.obligations.push(traits::Obligation::new(
ObligationCause::dummy(),
param_env,
ty::Predicate::WellFormed(revealed_ty),
ty::PredicateKind::WellFormed(revealed_ty),
));
obligations.add(
infcx
@ -1612,7 +1612,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.check_call_dest(body, term, &sig, destination, term_location);
self.prove_predicates(
sig.inputs_and_output.iter().map(|ty| ty::Predicate::WellFormed(ty)),
sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty)),
term_location.to_locations(),
ConstraintCategory::Boring,
);
@ -2017,7 +2017,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
traits::ObligationCauseCode::RepeatVec(should_suggest),
),
self.param_env,
ty::Predicate::Trait(
ty::PredicateKind::Trait(
ty::Binder::bind(ty::TraitPredicate {
trait_ref: ty::TraitRef::new(
self.tcx().require_lang_item(
@ -2686,7 +2686,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory,
) {
self.prove_predicates(
Some(ty::Predicate::Trait(
Some(ty::PredicateKind::Trait(
trait_ref.to_poly_trait_ref().to_poly_trait_predicate(),
hir::Constness::NotConst,
)),

View file

@ -3,7 +3,7 @@ use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_middle::mir::*;
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, adjustment::PointerCast, Predicate, Ty, TyCtxt};
use rustc_middle::ty::{self, adjustment::PointerCast, Ty, TyCtxt};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use std::borrow::Cow;
@ -24,20 +24,22 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -
let predicates = tcx.predicates_of(current);
for (predicate, _) in predicates.predicates {
match predicate {
Predicate::RegionOutlives(_)
| Predicate::TypeOutlives(_)
| Predicate::WellFormed(_)
| Predicate::Projection(_)
| Predicate::ConstEvaluatable(..)
| Predicate::ConstEquate(..) => continue,
Predicate::ObjectSafe(_) => {
ty::PredicateKind::RegionOutlives(_)
| ty::PredicateKind::TypeOutlives(_)
| ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::Projection(_)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => continue,
ty::PredicateKind::ObjectSafe(_) => {
bug!("object safe predicate on function: {:#?}", predicate)
}
Predicate::ClosureKind(..) => {
ty::PredicateKind::ClosureKind(..) => {
bug!("closure kind predicate on function: {:#?}", predicate)
}
Predicate::Subtype(_) => bug!("subtype predicate on function: {:#?}", predicate),
Predicate::Trait(pred, constness) => {
ty::PredicateKind::Subtype(_) => {
bug!("subtype predicate on function: {:#?}", predicate)
}
ty::PredicateKind::Trait(pred, constness) => {
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
continue;
}

View file

@ -91,13 +91,13 @@ where
let ty::GenericPredicates { parent: _, predicates } = predicates;
for (predicate, _span) in predicates {
match predicate {
ty::Predicate::Trait(poly_predicate, _) => {
ty::PredicateKind::Trait(poly_predicate, _) => {
let ty::TraitPredicate { trait_ref } = *poly_predicate.skip_binder();
if self.visit_trait(trait_ref) {
return true;
}
}
ty::Predicate::Projection(poly_predicate) => {
ty::PredicateKind::Projection(poly_predicate) => {
let ty::ProjectionPredicate { projection_ty, ty } =
*poly_predicate.skip_binder();
if ty.visit_with(self) {
@ -107,13 +107,13 @@ where
return true;
}
}
ty::Predicate::TypeOutlives(poly_predicate) => {
ty::PredicateKind::TypeOutlives(poly_predicate) => {
let ty::OutlivesPredicate(ty, _region) = *poly_predicate.skip_binder();
if ty.visit_with(self) {
return true;
}
}
ty::Predicate::RegionOutlives(..) => {}
ty::PredicateKind::RegionOutlives(..) => {}
_ => bug!("unexpected predicate: {:?}", predicate),
}
}

View file

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

View file

@ -341,7 +341,7 @@ impl AutoTraitFinder<'tcx> {
already_visited.remove(&pred);
self.add_user_pred(
&mut user_computed_preds,
ty::Predicate::Trait(pred, hir::Constness::NotConst),
ty::PredicateKind::Trait(pred, hir::Constness::NotConst),
);
predicates.push_back(pred);
} else {
@ -411,8 +411,10 @@ impl AutoTraitFinder<'tcx> {
) {
let mut should_add_new = true;
user_computed_preds.retain(|&old_pred| {
if let (&ty::Predicate::Trait(new_trait, _), ty::Predicate::Trait(old_trait, _)) =
(&new_pred, old_pred)
if let (
&ty::PredicateKind::Trait(new_trait, _),
ty::PredicateKind::Trait(old_trait, _),
) = (&new_pred, old_pred)
{
if new_trait.def_id() == old_trait.def_id() {
let new_substs = new_trait.skip_binder().trait_ref.substs;
@ -631,7 +633,7 @@ impl AutoTraitFinder<'tcx> {
// We check this by calling is_of_param on the relevant types
// from the various possible predicates
match &predicate {
&ty::Predicate::Trait(p, _) => {
&ty::PredicateKind::Trait(p, _) => {
if self.is_param_no_infer(p.skip_binder().trait_ref.substs)
&& !only_projections
&& is_new_pred
@ -640,7 +642,7 @@ impl AutoTraitFinder<'tcx> {
}
predicates.push_back(p);
}
&ty::Predicate::Projection(p) => {
&ty::PredicateKind::Projection(p) => {
debug!(
"evaluate_nested_obligations: examining projection predicate {:?}",
predicate
@ -765,12 +767,12 @@ impl AutoTraitFinder<'tcx> {
}
}
}
&ty::Predicate::RegionOutlives(ref binder) => {
&ty::PredicateKind::RegionOutlives(ref binder) => {
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
return false;
}
}
&ty::Predicate::TypeOutlives(ref binder) => {
&ty::PredicateKind::TypeOutlives(ref binder) => {
match (
binder.no_bound_vars(),
binder.map_bound_ref(|pred| pred.0).no_bound_vars(),

View file

@ -253,7 +253,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return;
}
match obligation.predicate {
ty::Predicate::Trait(ref trait_predicate, _) => {
ty::PredicateKind::Trait(ref trait_predicate, _) => {
let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
if self.tcx.sess.has_errors() && trait_predicate.references_error() {
@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
trait_pred
});
let unit_obligation = Obligation {
predicate: ty::Predicate::Trait(
predicate: ty::PredicateKind::Trait(
predicate,
hir::Constness::NotConst,
),
@ -489,14 +489,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
err
}
ty::Predicate::Subtype(ref predicate) => {
ty::PredicateKind::Subtype(ref predicate) => {
// Errors for Subtype predicates show up as
// `FulfillmentErrorCode::CodeSubtypeError`,
// not selection error.
span_bug!(span, "subtype requirement gave wrong error: `{:?}`", predicate)
}
ty::Predicate::RegionOutlives(ref predicate) => {
ty::PredicateKind::RegionOutlives(ref predicate) => {
let predicate = self.resolve_vars_if_possible(predicate);
let err = self
.region_outlives_predicate(&obligation.cause, &predicate)
@ -512,7 +512,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
)
}
ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => {
ty::PredicateKind::Projection(..) | ty::PredicateKind::TypeOutlives(..) => {
let predicate = self.resolve_vars_if_possible(&obligation.predicate);
struct_span_err!(
self.tcx.sess,
@ -523,12 +523,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
)
}
ty::Predicate::ObjectSafe(trait_def_id) => {
ty::PredicateKind::ObjectSafe(trait_def_id) => {
let violations = self.tcx.object_safety_violations(trait_def_id);
report_object_safety_error(self.tcx, span, trait_def_id, violations)
}
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
let found_kind = self.closure_kind(closure_substs).unwrap();
let closure_span =
self.tcx.sess.source_map().guess_head_span(
@ -587,7 +587,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return;
}
ty::Predicate::WellFormed(ty) => {
ty::PredicateKind::WellFormed(ty) => {
if !self.tcx.sess.opts.debugging_opts.chalk {
// WF predicates cannot themselves make
// errors. They can only block due to
@ -605,7 +605,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
}
}
ty::Predicate::ConstEvaluatable(..) => {
ty::PredicateKind::ConstEvaluatable(..) => {
// Errors for `ConstEvaluatable` predicates show up as
// `SelectionError::ConstEvalFailure`,
// not `Unimplemented`.
@ -1047,7 +1047,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
}
let (cond, error) = match (cond, error) {
(&ty::Predicate::Trait(..), &ty::Predicate::Trait(ref error, _)) => (cond, error),
(&ty::PredicateKind::Trait(..), &ty::PredicateKind::Trait(ref error, _)) => {
(cond, error)
}
_ => {
// FIXME: make this work in other cases too.
return false;
@ -1055,7 +1057,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
};
for obligation in super::elaborate_predicates(self.tcx, std::iter::once(*cond)) {
if let ty::Predicate::Trait(implication, _) = obligation.predicate {
if let ty::PredicateKind::Trait(implication, _) = obligation.predicate {
let error = error.to_poly_trait_ref();
let implication = implication.to_poly_trait_ref();
// FIXME: I'm just not taking associated types at all here.
@ -1135,7 +1137,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
//
// this can fail if the problem was higher-ranked, in which
// cause I have no idea for a good error message.
if let ty::Predicate::Projection(ref data) = predicate {
if let ty::PredicateKind::Projection(ref data) = predicate {
let mut selcx = SelectionContext::new(self);
let (data, _) = self.replace_bound_vars_with_fresh_vars(
obligation.cause.span,
@ -1416,7 +1418,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
}
let mut err = match predicate {
ty::Predicate::Trait(ref data, _) => {
ty::PredicateKind::Trait(ref data, _) => {
let trait_ref = data.to_poly_trait_ref();
let self_ty = trait_ref.self_ty();
debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind, trait_ref);
@ -1515,7 +1517,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
err
}
ty::Predicate::WellFormed(ty) => {
ty::PredicateKind::WellFormed(ty) => {
// Same hacky approach as above to avoid deluging user
// with error messages.
if ty.references_error() || self.tcx.sess.has_errors() {
@ -1524,7 +1526,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
self.need_type_info_err(body_id, span, ty, ErrorCode::E0282)
}
ty::Predicate::Subtype(ref data) => {
ty::PredicateKind::Subtype(ref data) => {
if data.references_error() || self.tcx.sess.has_errors() {
// no need to overload user in such cases
return;
@ -1534,7 +1536,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
assert!(a.is_ty_var() && b.is_ty_var());
self.need_type_info_err(body_id, span, a, ErrorCode::E0282)
}
ty::Predicate::Projection(ref data) => {
ty::PredicateKind::Projection(ref data) => {
let trait_ref = data.to_poly_trait_ref(self.tcx);
let self_ty = trait_ref.self_ty();
let ty = data.skip_binder().ty;
@ -1658,7 +1660,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
obligation: &PredicateObligation<'tcx>,
) {
if let (
ty::Predicate::Trait(pred, _),
ty::PredicateKind::Trait(pred, _),
ObligationCauseCode::BindingObligation(item_def_id, span),
) = (&obligation.predicate, &obligation.cause.code)
{

View file

@ -1238,7 +1238,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// bound was introduced. At least one generator should be present for this diagnostic to be
// modified.
let (mut trait_ref, mut target_ty) = match obligation.predicate {
ty::Predicate::Trait(p, _) => {
ty::PredicateKind::Trait(p, _) => {
(Some(p.skip_binder().trait_ref), Some(p.skip_binder().self_ty()))
}
_ => (None, None),

View file

@ -323,7 +323,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
let infcx = self.selcx.infcx();
match obligation.predicate {
ty::Predicate::Trait(ref data, _) => {
ty::PredicateKind::Trait(ref data, _) => {
let trait_obligation = obligation.with(*data);
if data.is_global() {
@ -378,14 +378,14 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::RegionOutlives(ref binder) => {
ty::PredicateKind::RegionOutlives(ref binder) => {
match infcx.region_outlives_predicate(&obligation.cause, binder) {
Ok(()) => ProcessResult::Changed(vec![]),
Err(_) => ProcessResult::Error(CodeSelectionError(Unimplemented)),
}
}
ty::Predicate::TypeOutlives(ref binder) => {
ty::PredicateKind::TypeOutlives(ref binder) => {
// Check if there are higher-ranked vars.
match binder.no_bound_vars() {
// If there are, inspect the underlying type further.
@ -429,7 +429,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::Projection(ref data) => {
ty::PredicateKind::Projection(ref data) => {
let project_obligation = obligation.with(*data);
match project::poly_project_and_unify_type(self.selcx, &project_obligation) {
Ok(None) => {
@ -443,7 +443,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::ObjectSafe(trait_def_id) => {
ty::PredicateKind::ObjectSafe(trait_def_id) => {
if !self.selcx.tcx().is_object_safe(trait_def_id) {
ProcessResult::Error(CodeSelectionError(Unimplemented))
} else {
@ -451,7 +451,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::ClosureKind(_, closure_substs, kind) => {
ty::PredicateKind::ClosureKind(_, closure_substs, kind) => {
match self.selcx.infcx().closure_kind(closure_substs) {
Some(closure_kind) => {
if closure_kind.extends(kind) {
@ -464,7 +464,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::WellFormed(ty) => {
ty::PredicateKind::WellFormed(ty) => {
match wf::obligations(
self.selcx.infcx(),
obligation.param_env,
@ -481,7 +481,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::Subtype(ref subtype) => {
ty::PredicateKind::Subtype(ref subtype) => {
match self.selcx.infcx().subtype_predicate(
&obligation.cause,
obligation.param_env,
@ -510,7 +510,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
match self.selcx.infcx().const_eval_resolve(
obligation.param_env,
def_id,

View file

@ -334,7 +334,7 @@ pub fn normalize_param_env_or_error<'tcx>(
// TypeOutlives predicates - these are normally used by regionck.
let outlives_predicates: Vec<_> = predicates
.drain_filter(|predicate| match predicate {
ty::Predicate::TypeOutlives(..) => true,
ty::PredicateKind::TypeOutlives(..) => true,
_ => false,
})
.collect();

View file

@ -246,7 +246,7 @@ fn predicates_reference_self(
.map(|(predicate, sp)| (predicate.subst_supertrait(tcx, &trait_ref), sp))
.filter_map(|(predicate, &sp)| {
match predicate {
ty::Predicate::Trait(ref data, _) => {
ty::PredicateKind::Trait(ref data, _) => {
// In the case of a trait predicate, we can skip the "self" type.
if data.skip_binder().trait_ref.substs[1..].iter().any(has_self_ty) {
Some(sp)
@ -254,7 +254,7 @@ fn predicates_reference_self(
None
}
}
ty::Predicate::Projection(ref data) => {
ty::PredicateKind::Projection(ref data) => {
// And similarly for projections. This should be redundant with
// the previous check because any projection should have a
// matching `Trait` predicate with the same inputs, but we do
@ -276,14 +276,14 @@ fn predicates_reference_self(
None
}
}
ty::Predicate::WellFormed(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::TypeOutlives(..)
| ty::Predicate::RegionOutlives(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::Subtype(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => None,
ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::TypeOutlives(..)
| ty::PredicateKind::RegionOutlives(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => None,
}
})
.collect()
@ -305,18 +305,18 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let predicates = tcx.predicates_of(def_id);
let predicates = predicates.instantiate_identity(tcx).predicates;
elaborate_predicates(tcx, predicates.into_iter()).any(|obligation| match obligation.predicate {
ty::Predicate::Trait(ref trait_pred, _) => {
ty::PredicateKind::Trait(ref trait_pred, _) => {
trait_pred.def_id() == sized_def_id && trait_pred.skip_binder().self_ty().is_param(0)
}
ty::Predicate::Projection(..)
| ty::Predicate::Subtype(..)
| ty::Predicate::RegionOutlives(..)
| ty::Predicate::WellFormed(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::TypeOutlives(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => false,
ty::PredicateKind::Projection(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::RegionOutlives(..)
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::TypeOutlives(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => false,
})
}

View file

@ -671,7 +671,9 @@ fn prune_cache_value_obligations<'a, 'tcx>(
// indirect obligations (e.g., we project to `?0`,
// but we have `T: Foo<X = ?1>` and `?1: Bar<X =
// ?0>`).
ty::Predicate::Projection(ref data) => infcx.unresolved_type_vars(&data.ty()).is_some(),
ty::PredicateKind::Projection(ref data) => {
infcx.unresolved_type_vars(&data.ty()).is_some()
}
// We are only interested in `T: Foo<X = U>` predicates, whre
// `U` references one of `unresolved_type_vars`. =)
@ -928,7 +930,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
let infcx = selcx.infcx();
for predicate in env_predicates {
debug!("assemble_candidates_from_predicates: predicate={:?}", predicate);
if let ty::Predicate::Projection(data) = predicate {
if let ty::PredicateKind::Projection(data) = predicate {
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id;
let is_match = same_def_id
@ -1164,7 +1166,7 @@ fn confirm_object_candidate<'cx, 'tcx>(
// select only those projections that are actually projecting an
// item with the correct name
let env_predicates = env_predicates.filter_map(|o| match o.predicate {
ty::Predicate::Projection(data) => {
ty::PredicateKind::Projection(data) => {
if data.projection_def_id() == obligation.predicate.item_def_id {
Some(data)
} else {

View file

@ -1,6 +1,6 @@
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
use crate::traits::query::Fallible;
use rustc_middle::ty::{ParamEnvAnd, Predicate, TyCtxt};
use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
pub use rustc_middle::traits::query::type_op::ProvePredicate;
@ -15,7 +15,7 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
// `&T`, accounts for about 60% percentage of the predicates
// we have to prove. No need to canonicalize and all that for
// such cases.
if let Predicate::Trait(trait_ref, _) = key.value.predicate {
if let ty::PredicateKind::Trait(trait_ref, _) = key.value.predicate {
if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
if trait_ref.def_id() == sized_def_id {
if trait_ref.skip_binder().self_ty().is_trivially_sized(tcx) {

View file

@ -414,13 +414,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
match obligation.predicate {
ty::Predicate::Trait(ref t, _) => {
ty::PredicateKind::Trait(ref t, _) => {
debug_assert!(!t.has_escaping_bound_vars());
let obligation = obligation.with(*t);
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
}
ty::Predicate::Subtype(ref p) => {
ty::PredicateKind::Subtype(ref p) => {
// Does this code ever run?
match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
Some(Ok(InferOk { mut obligations, .. })) => {
@ -435,7 +435,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::Predicate::WellFormed(ty) => match wf::obligations(
ty::PredicateKind::WellFormed(ty) => match wf::obligations(
self.infcx,
obligation.param_env,
obligation.cause.body_id,
@ -449,12 +449,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
None => Ok(EvaluatedToAmbig),
},
ty::Predicate::TypeOutlives(..) | ty::Predicate::RegionOutlives(..) => {
ty::PredicateKind::TypeOutlives(..) | ty::PredicateKind::RegionOutlives(..) => {
// We do not consider region relationships when evaluating trait matches.
Ok(EvaluatedToOkModuloRegions)
}
ty::Predicate::ObjectSafe(trait_def_id) => {
ty::PredicateKind::ObjectSafe(trait_def_id) => {
if self.tcx().is_object_safe(trait_def_id) {
Ok(EvaluatedToOk)
} else {
@ -462,7 +462,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::Predicate::Projection(ref data) => {
ty::PredicateKind::Projection(ref data) => {
let project_obligation = obligation.with(*data);
match project::poly_project_and_unify_type(self, &project_obligation) {
Ok(Some(mut subobligations)) => {
@ -483,7 +483,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::Predicate::ClosureKind(_, closure_substs, kind) => {
ty::PredicateKind::ClosureKind(_, closure_substs, kind) => {
match self.infcx.closure_kind(closure_substs) {
Some(closure_kind) => {
if closure_kind.extends(kind) {
@ -496,7 +496,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
match self.tcx().const_eval_resolve(
obligation.param_env,
def_id,
@ -676,7 +676,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// if the regions match exactly.
let cycle = stack.iter().skip(1).take_while(|s| s.depth >= cycle_depth);
let cycle = cycle.map(|stack| {
ty::Predicate::Trait(stack.obligation.predicate, hir::Constness::NotConst)
ty::PredicateKind::Trait(stack.obligation.predicate, hir::Constness::NotConst)
});
if self.coinductive_match(cycle) {
debug!("evaluate_stack({:?}) --> recursive, coinductive", stack.fresh_trait_ref);
@ -792,7 +792,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
let result = match predicate {
ty::Predicate::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,
};
debug!("coinductive_predicate({:?}) = {:?}", predicate, result);
@ -2921,7 +2921,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligations.push(Obligation::new(
obligation.cause.clone(),
obligation.param_env,
ty::Predicate::ClosureKind(closure_def_id, substs, kind),
ty::PredicateKind::ClosureKind(closure_def_id, substs, kind),
));
}

View file

@ -73,28 +73,28 @@ pub fn predicate_obligations<'a, 'tcx>(
// (*) ok to skip binders, because wf code is prepared for it
match *predicate {
ty::Predicate::Trait(ref t, _) => {
ty::PredicateKind::Trait(ref t, _) => {
wf.compute_trait_ref(&t.skip_binder().trait_ref, Elaborate::None); // (*)
}
ty::Predicate::RegionOutlives(..) => {}
ty::Predicate::TypeOutlives(ref t) => {
ty::PredicateKind::RegionOutlives(..) => {}
ty::PredicateKind::TypeOutlives(ref t) => {
wf.compute(t.skip_binder().0);
}
ty::Predicate::Projection(ref t) => {
ty::PredicateKind::Projection(ref t) => {
let t = t.skip_binder(); // (*)
wf.compute_projection(t.projection_ty);
wf.compute(t.ty);
}
ty::Predicate::WellFormed(t) => {
ty::PredicateKind::WellFormed(t) => {
wf.compute(t);
}
ty::Predicate::ObjectSafe(_) => {}
ty::Predicate::ClosureKind(..) => {}
ty::Predicate::Subtype(ref data) => {
ty::PredicateKind::ObjectSafe(_) => {}
ty::PredicateKind::ClosureKind(..) => {}
ty::PredicateKind::Subtype(ref data) => {
wf.compute(data.skip_binder().a); // (*)
wf.compute(data.skip_binder().b); // (*)
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
let obligations = wf.nominal_obligations(def_id, substs);
wf.out.extend(obligations);
@ -171,7 +171,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
_ => impl_item_ref.span,
};
match pred {
ty::Predicate::Projection(proj) => {
ty::PredicateKind::Projection(proj) => {
// The obligation comes not from the current `impl` nor the `trait` being
// implemented, but rather from a "second order" obligation, like in
// `src/test/ui/associated-types/point-at-type-on-obligation-failure.rs`.
@ -194,7 +194,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>(
}
}
}
ty::Predicate::Trait(pred, _) => {
ty::PredicateKind::Trait(pred, _) => {
// An associated item obligation born out of the `trait` failed to be met. An example
// can be seen in `ui/associated-types/point-at-type-on-obligation-failure-2.rs`.
debug!("extended_cause_with_original_assoc_item_obligation trait proj {:?}", pred);
@ -276,7 +276,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
}
self.out.extend(trait_ref.substs.types().filter(|ty| !ty.has_escaping_bound_vars()).map(
|ty| traits::Obligation::new(cause.clone(), param_env, ty::Predicate::WellFormed(ty)),
|ty| {
traits::Obligation::new(cause.clone(), param_env, ty::PredicateKind::WellFormed(ty))
},
));
}
@ -305,7 +307,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
let obligations = self.nominal_obligations(def_id, substs);
self.out.extend(obligations);
let predicate = ty::Predicate::ConstEvaluatable(def_id, substs);
let predicate = ty::PredicateKind::ConstEvaluatable(def_id, substs);
let cause = self.cause(traits::MiscObligation);
self.out.push(traits::Obligation::new(cause, self.param_env, predicate));
}
@ -411,9 +413,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
self.out.push(traits::Obligation::new(
cause,
param_env,
ty::Predicate::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
rty, r,
))),
ty::PredicateKind::TypeOutlives(ty::Binder::dummy(
ty::OutlivesPredicate(rty, r),
)),
));
}
}
@ -502,7 +504,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
traits::Obligation::new(
cause.clone(),
param_env,
ty::Predicate::ObjectSafe(did),
ty::PredicateKind::ObjectSafe(did),
)
}));
}
@ -528,7 +530,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
self.out.push(traits::Obligation::new(
cause,
param_env,
ty::Predicate::WellFormed(ty),
ty::PredicateKind::WellFormed(ty),
));
} else {
// Yes, resolved, proceed with the result.

View file

@ -95,27 +95,27 @@ fn compute_implied_outlives_bounds<'tcx>(
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
assert!(!obligation.has_escaping_bound_vars());
match obligation.predicate {
ty::Predicate::Trait(..)
| ty::Predicate::Subtype(..)
| ty::Predicate::Projection(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => vec![],
ty::PredicateKind::Trait(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => vec![],
ty::Predicate::WellFormed(subty) => {
ty::PredicateKind::WellFormed(subty) => {
wf_types.push(subty);
vec![]
}
ty::Predicate::RegionOutlives(ref data) => match data.no_bound_vars() {
ty::PredicateKind::RegionOutlives(ref data) => match data.no_bound_vars() {
None => vec![],
Some(ty::OutlivesPredicate(r_a, r_b)) => {
vec![OutlivesBound::RegionSubRegion(r_b, r_a)]
}
},
ty::Predicate::TypeOutlives(ref data) => match data.no_bound_vars() {
ty::PredicateKind::TypeOutlives(ref data) => match data.no_bound_vars() {
None => vec![],
Some(ty::OutlivesPredicate(ty_a, r_b)) => {
let ty_a = infcx.resolve_vars_if_possible(&ty_a);

View file

@ -41,14 +41,14 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>(
fn not_outlives_predicate(p: &ty::Predicate<'_>) -> bool {
match p {
ty::Predicate::RegionOutlives(..) | ty::Predicate::TypeOutlives(..) => false,
ty::Predicate::Trait(..)
| ty::Predicate::Projection(..)
| ty::Predicate::WellFormed(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::Subtype(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => true,
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
ty::PredicateKind::Trait(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => true,
}
}

View file

@ -7,7 +7,8 @@ use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
use rustc_middle::ty::{
FnSig, Lift, ParamEnv, ParamEnvAnd, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable, Variance,
self, FnSig, Lift, ParamEnv, ParamEnvAnd, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable,
Variance,
};
use rustc_span::DUMMY_SP;
use rustc_trait_selection::infer::InferCtxtBuilderExt;
@ -140,7 +141,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
self.prove_predicate(Predicate::WellFormed(impl_self_ty));
self.prove_predicate(ty::PredicateKind::WellFormed(impl_self_ty));
}
// In addition to proving the predicates, we have to
@ -154,7 +155,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
// them? This would only be relevant if some input
// type were ill-formed but did not appear in `ty`,
// which...could happen with normalization...
self.prove_predicate(Predicate::WellFormed(ty));
self.prove_predicate(ty::PredicateKind::WellFormed(ty));
Ok(())
}
}

View file

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

View file

@ -206,7 +206,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
obligation.predicate
);
if let ty::Predicate::Projection(ref proj_predicate) = obligation.predicate {
if let ty::PredicateKind::Projection(ref proj_predicate) = obligation.predicate {
// Given a Projection predicate, we can potentially infer
// the complete signature.
self.deduce_sig_from_projection(Some(obligation.cause.span), proj_predicate)
@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
all_obligations.push(Obligation::new(
cause,
self.param_env,
ty::Predicate::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
ty::PredicateKind::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
supplied_ty,
closure_body_region,
))),
@ -641,7 +641,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// where R is the return type we are expecting. This type `T`
// will be our output.
let output_ty = self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| {
if let ty::Predicate::Projection(ref proj_predicate) = obligation.predicate {
if let ty::PredicateKind::Projection(ref proj_predicate) = obligation.predicate {
self.deduce_future_output_from_projection(obligation.cause.span, proj_predicate)
} else {
None

View file

@ -597,7 +597,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
let obligation = queue.remove(0);
debug!("coerce_unsized resolve step: {:?}", obligation);
let trait_pred = match obligation.predicate {
ty::Predicate::Trait(trait_pred, _) if traits.contains(&trait_pred.def_id()) => {
ty::PredicateKind::Trait(trait_pred, _)
if traits.contains(&trait_pred.def_id()) =>
{
if unsize_did == trait_pred.def_id() {
let unsize_ty = trait_pred.skip_binder().trait_ref.substs[1].expect_ty();
if let ty::Tuple(..) = unsize_ty.kind {

View file

@ -644,7 +644,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.unwrap()
.def_id;
let predicate =
ty::Predicate::Projection(ty::Binder::bind(ty::ProjectionPredicate {
ty::PredicateKind::Projection(ty::Binder::bind(ty::ProjectionPredicate {
// `<T as Deref>::Output`
projection_ty: ty::ProjectionTy {
// `T`

View file

@ -231,8 +231,10 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let predicate_matches_closure = |p: &'_ Predicate<'tcx>| {
let mut relator: SimpleEqRelation<'tcx> = SimpleEqRelation::new(tcx, self_param_env);
match (predicate, p) {
(Predicate::Trait(a, _), Predicate::Trait(b, _)) => relator.relate(a, b).is_ok(),
(Predicate::Projection(a), Predicate::Projection(b)) => {
(ty::PredicateKind::Trait(a, _), ty::PredicateKind::Trait(b, _)) => {
relator.relate(a, b).is_ok()
}
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
relator.relate(a, b).is_ok()
}
_ => predicate == p,

View file

@ -575,7 +575,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
traits::elaborate_predicates(self.tcx, predicates.predicates.iter().copied())
.filter_map(|obligation| match obligation.predicate {
ty::Predicate::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
.predicates
.iter()

View file

@ -401,7 +401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
obligations.push(traits::Obligation::new(
cause,
self.param_env,
ty::Predicate::WellFormed(method_ty),
ty::PredicateKind::WellFormed(method_ty),
));
let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };

View file

@ -797,21 +797,21 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
// FIXME: do we want to commit to this behavior for param bounds?
let bounds = self.param_env.caller_bounds.iter().filter_map(|predicate| match *predicate {
ty::Predicate::Trait(ref trait_predicate, _) => {
ty::PredicateKind::Trait(ref trait_predicate, _) => {
match trait_predicate.skip_binder().trait_ref.self_ty().kind {
ty::Param(ref p) if *p == param_ty => Some(trait_predicate.to_poly_trait_ref()),
_ => None,
}
}
ty::Predicate::Subtype(..)
| ty::Predicate::Projection(..)
| ty::Predicate::RegionOutlives(..)
| ty::Predicate::WellFormed(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::TypeOutlives(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => None,
ty::PredicateKind::Subtype(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::RegionOutlives(..)
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::TypeOutlives(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => None,
});
self.elaborate_bounds(bounds, |this, poly_trait_ref, item| {

View file

@ -574,7 +574,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut bound_spans = vec![];
let mut collect_type_param_suggestions =
|self_ty: Ty<'_>, parent_pred: &ty::Predicate<'_>, obligation: &str| {
if let (ty::Param(_), ty::Predicate::Trait(p, _)) =
if let (ty::Param(_), ty::PredicateKind::Trait(p, _)) =
(&self_ty.kind, parent_pred)
{
if let ty::Adt(def, _) = p.skip_binder().trait_ref.self_ty().kind {
@ -628,7 +628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
let mut format_pred = |pred| {
match pred {
ty::Predicate::Projection(pred) => {
ty::PredicateKind::Projection(pred) => {
// `<Foo as Iterator>::Item = String`.
let trait_ref =
pred.skip_binder().projection_ty.trait_ref(self.tcx);
@ -646,7 +646,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
bound_span_label(trait_ref.self_ty(), &obligation, &quiet);
Some((obligation, trait_ref.self_ty()))
}
ty::Predicate::Trait(poly_trait_ref, _) => {
ty::PredicateKind::Trait(poly_trait_ref, _) => {
let p = poly_trait_ref.skip_binder().trait_ref;
let self_ty = p.self_ty();
let path = p.print_only_trait_path();
@ -949,8 +949,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
unsatisfied_predicates.iter().all(|(p, _)| match p {
// Hide traits if they are present in predicates as they can be fixed without
// having to implement them.
ty::Predicate::Trait(t, _) => t.def_id() == info.def_id,
ty::Predicate::Projection(p) => p.item_def_id() == info.def_id,
ty::PredicateKind::Trait(t, _) => t.def_id() == info.def_id,
ty::PredicateKind::Projection(p) => p.item_def_id() == info.def_id,
_ => false,
}) && (type_is_local || info.def_id.is_local())
&& self

View file

@ -2224,7 +2224,7 @@ fn bounds_from_generic_predicates(
for (predicate, _) in predicates.predicates {
debug!("predicate {:?}", predicate);
match predicate {
ty::Predicate::Trait(trait_predicate, _) => {
ty::PredicateKind::Trait(trait_predicate, _) => {
let entry = types.entry(trait_predicate.skip_binder().self_ty()).or_default();
let def_id = trait_predicate.skip_binder().def_id();
if Some(def_id) != tcx.lang_items().sized_trait() {
@ -2233,7 +2233,7 @@ fn bounds_from_generic_predicates(
entry.push(trait_predicate.skip_binder().def_id());
}
}
ty::Predicate::Projection(projection_pred) => {
ty::PredicateKind::Projection(projection_pred) => {
projections.push(projection_pred);
}
_ => {}
@ -2770,7 +2770,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
parent: None,
predicates: tcx.arena.alloc_from_iter(self.param_env.caller_bounds.iter().filter_map(
|&predicate| match predicate {
ty::Predicate::Trait(ref data, _)
ty::PredicateKind::Trait(ref data, _)
if data.skip_binder().self_ty().is_param(index) =>
{
// HACK(eddyb) should get the original `Span`.
@ -3379,7 +3379,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.register_predicate(traits::Obligation::new(
cause,
self.param_env,
ty::Predicate::ConstEvaluatable(def_id, substs),
ty::PredicateKind::ConstEvaluatable(def_id, substs),
));
}
@ -3428,7 +3428,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.register_predicate(traits::Obligation::new(
cause,
self.param_env,
ty::Predicate::WellFormed(ty),
ty::PredicateKind::WellFormed(ty),
));
}
@ -3858,17 +3858,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.pending_obligations()
.into_iter()
.filter_map(move |obligation| match obligation.predicate {
ty::Predicate::Projection(ref data) => {
ty::PredicateKind::Projection(ref data) => {
Some((data.to_poly_trait_ref(self.tcx), obligation))
}
ty::Predicate::Trait(ref data, _) => Some((data.to_poly_trait_ref(), obligation)),
ty::Predicate::Subtype(..) => None,
ty::Predicate::RegionOutlives(..) => None,
ty::Predicate::TypeOutlives(..) => None,
ty::Predicate::WellFormed(..) => None,
ty::Predicate::ObjectSafe(..) => None,
ty::Predicate::ConstEvaluatable(..) => None,
ty::Predicate::ConstEquate(..) => None,
ty::PredicateKind::Trait(ref data, _) => {
Some((data.to_poly_trait_ref(), obligation))
}
ty::PredicateKind::Subtype(..) => None,
ty::PredicateKind::RegionOutlives(..) => None,
ty::PredicateKind::TypeOutlives(..) => None,
ty::PredicateKind::WellFormed(..) => None,
ty::PredicateKind::ObjectSafe(..) => None,
ty::PredicateKind::ConstEvaluatable(..) => None,
ty::PredicateKind::ConstEquate(..) => None,
// N.B., this predicate is created by breaking down a
// `ClosureType: FnFoo()` predicate, where
// `ClosureType` represents some `Closure`. It can't
@ -3877,7 +3879,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// this closure yet; this is exactly why the other
// code is looking for a self type of a unresolved
// inference variable.
ty::Predicate::ClosureKind(..) => None,
ty::PredicateKind::ClosureKind(..) => None,
})
.filter(move |(tr, _)| self.self_type_matches_expected_vid(*tr, ty_var_root))
}
@ -4206,7 +4208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
continue;
}
if let ty::Predicate::Trait(predicate, _) = error.obligation.predicate {
if let ty::PredicateKind::Trait(predicate, _) = error.obligation.predicate {
// Collect the argument position for all arguments that could have caused this
// `FulfillmentError`.
let mut referenced_in = final_arg_types
@ -4253,7 +4255,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let hir::ExprKind::Path(qpath) = &path.kind {
if let hir::QPath::Resolved(_, path) = &qpath {
for error in errors {
if let ty::Predicate::Trait(predicate, _) = error.obligation.predicate {
if let ty::PredicateKind::Trait(predicate, _) = error.obligation.predicate {
// If any of the type arguments in this path segment caused the
// `FullfillmentError`, point at its span (#61860).
for arg in path
@ -5322,7 +5324,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
let predicate =
ty::Predicate::Projection(ty::Binder::bind(ty::ProjectionPredicate {
ty::PredicateKind::Projection(ty::Binder::bind(ty::ProjectionPredicate {
projection_ty,
ty: expected,
}));

View file

@ -425,7 +425,7 @@ fn check_type_defn<'tcx, F>(
fcx.register_predicate(traits::Obligation::new(
cause,
fcx.param_env,
ty::Predicate::ConstEvaluatable(discr_def_id.to_def_id(), discr_substs),
ty::PredicateKind::ConstEvaluatable(discr_def_id.to_def_id(), discr_substs),
));
}
}

View file

@ -549,7 +549,9 @@ fn type_param_predicates(
icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true))
.into_iter()
.filter(|(predicate, _)| match predicate {
ty::Predicate::Trait(ref data, _) => data.skip_binder().self_ty().is_param(index),
ty::PredicateKind::Trait(ref data, _) => {
data.skip_binder().self_ty().is_param(index)
}
_ => false,
}),
);
@ -994,7 +996,7 @@ fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredi
// which will, in turn, reach indirect supertraits.
for &(pred, span) in superbounds {
debug!("superbound: {:?}", pred);
if let ty::Predicate::Trait(bound, _) = pred {
if let ty::PredicateKind::Trait(bound, _) = pred {
tcx.at(span).super_predicates_of(bound.def_id());
}
}
@ -1899,7 +1901,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
let re_root_empty = tcx.lifetimes.re_root_empty;
let predicate = ty::OutlivesPredicate(ty, re_root_empty);
predicates.push((
ty::Predicate::TypeOutlives(ty::Binder::dummy(predicate)),
ty::PredicateKind::TypeOutlives(ty::Binder::dummy(predicate)),
span,
));
}
@ -1928,7 +1930,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
&hir::GenericBound::Outlives(ref lifetime) => {
let region = AstConv::ast_region_to_region(&icx, lifetime, None);
let pred = ty::Binder::bind(ty::OutlivesPredicate(ty, region));
predicates.push((ty::Predicate::TypeOutlives(pred), lifetime.span))
predicates.push((ty::PredicateKind::TypeOutlives(pred), lifetime.span))
}
}
}
@ -1945,7 +1947,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
};
let pred = ty::Binder::bind(ty::OutlivesPredicate(r1, r2));
(ty::Predicate::RegionOutlives(pred), span)
(ty::PredicateKind::RegionOutlives(pred), span)
}))
}
@ -2116,7 +2118,7 @@ fn predicates_from_bound<'tcx>(
hir::GenericBound::Outlives(ref lifetime) => {
let region = astconv.ast_region_to_region(lifetime, None);
let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region));
vec![(ty::Predicate::TypeOutlives(pred), lifetime.span)]
vec![(ty::PredicateKind::TypeOutlives(pred), lifetime.span)]
}
}
}

View file

@ -180,7 +180,7 @@ pub fn setup_constraining_predicates<'tcx>(
changed = false;
for j in i..predicates.len() {
if let ty::Predicate::Projection(ref poly_projection) = predicates[j].0 {
if let ty::PredicateKind::Projection(ref poly_projection) = predicates[j].0 {
// Note that we can skip binder here because the impl
// trait ref never contains any late-bound regions.
let projection = poly_projection.skip_binder();

View file

@ -204,7 +204,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
// the functions in `cgp` add the constrained parameters to a list of
// unconstrained parameters.
for (predicate, _) in impl_generic_predicates.predicates.iter() {
if let ty::Predicate::Projection(proj) = predicate {
if let ty::PredicateKind::Projection(proj) = predicate {
let projection_ty = proj.skip_binder().projection_ty;
let projected_ty = proj.skip_binder().ty;
@ -374,7 +374,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: &ty::Predicate<'t
_ if predicate.is_global() => (),
// We allow specializing on explicitly marked traits with no associated
// items.
ty::Predicate::Trait(pred, hir::Constness::NotConst) => {
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
if !matches!(
trait_predicate_kind(tcx, predicate),
Some(TraitSpecializationKind::Marker)
@ -402,18 +402,18 @@ fn trait_predicate_kind<'tcx>(
predicate: &ty::Predicate<'tcx>,
) -> Option<TraitSpecializationKind> {
match predicate {
ty::Predicate::Trait(pred, hir::Constness::NotConst) => {
ty::PredicateKind::Trait(pred, hir::Constness::NotConst) => {
Some(tcx.trait_def(pred.def_id()).specialization_kind)
}
ty::Predicate::Trait(_, hir::Constness::Const)
| ty::Predicate::RegionOutlives(_)
| ty::Predicate::TypeOutlives(_)
| ty::Predicate::Projection(_)
| ty::Predicate::WellFormed(_)
| ty::Predicate::Subtype(_)
| ty::Predicate::ObjectSafe(_)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => None,
ty::PredicateKind::Trait(_, hir::Constness::Const)
| ty::PredicateKind::RegionOutlives(_)
| ty::PredicateKind::TypeOutlives(_)
| ty::PredicateKind::Projection(_)
| ty::PredicateKind::WellFormed(_)
| ty::PredicateKind::Subtype(_)
| ty::PredicateKind::ObjectSafe(_)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => None,
}
}

View file

@ -30,7 +30,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
// process predicates and convert to `RequiredPredicates` entry, see below
for &(predicate, span) in predicates.predicates {
match predicate {
ty::Predicate::TypeOutlives(predicate) => {
ty::PredicateKind::TypeOutlives(predicate) => {
let OutlivesPredicate(ref ty, ref reg) = predicate.skip_binder();
insert_outlives_predicate(
tcx,
@ -41,7 +41,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
)
}
ty::Predicate::RegionOutlives(predicate) => {
ty::PredicateKind::RegionOutlives(predicate) => {
let OutlivesPredicate(ref reg1, ref reg2) = predicate.skip_binder();
insert_outlives_predicate(
tcx,
@ -52,14 +52,14 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
)
}
ty::Predicate::Trait(..)
| ty::Predicate::Projection(..)
| ty::Predicate::WellFormed(..)
| ty::Predicate::ObjectSafe(..)
| ty::Predicate::ClosureKind(..)
| ty::Predicate::Subtype(..)
| ty::Predicate::ConstEvaluatable(..)
| ty::Predicate::ConstEquate(..) => (),
ty::PredicateKind::Trait(..)
| ty::PredicateKind::Projection(..)
| ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Subtype(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => (),
}
}

View file

@ -31,8 +31,8 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
let mut pred: Vec<String> = predicates
.iter()
.map(|(out_pred, _)| match out_pred {
ty::Predicate::RegionOutlives(p) => p.to_string(),
ty::Predicate::TypeOutlives(p) => p.to_string(),
ty::PredicateKind::RegionOutlives(p) => p.to_string(),
ty::PredicateKind::TypeOutlives(p) => p.to_string(),
err => bug!("unexpected predicate {:?}", err),
})
.collect();
@ -84,13 +84,13 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
let predicates = &*tcx.arena.alloc_from_iter(set.iter().filter_map(
|(ty::OutlivesPredicate(kind1, region2), &span)| match kind1.unpack() {
GenericArgKind::Type(ty1) => Some((
ty::Predicate::TypeOutlives(ty::Binder::bind(ty::OutlivesPredicate(
ty::PredicateKind::TypeOutlives(ty::Binder::bind(ty::OutlivesPredicate(
ty1, region2,
))),
span,
)),
GenericArgKind::Lifetime(region1) => Some((
ty::Predicate::RegionOutlives(ty::Binder::bind(ty::OutlivesPredicate(
ty::PredicateKind::RegionOutlives(ty::Binder::bind(ty::OutlivesPredicate(
region1, region2,
))),
span,

View file

@ -316,10 +316,10 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
pred: ty::Predicate<'tcx>,
) -> FxHashSet<GenericParamDef> {
let regions = match pred {
ty::Predicate::Trait(poly_trait_pred, _) => {
ty::PredicateKind::Trait(poly_trait_pred, _) => {
tcx.collect_referenced_late_bound_regions(&poly_trait_pred)
}
ty::Predicate::Projection(poly_proj_pred) => {
ty::PredicateKind::Projection(poly_proj_pred) => {
tcx.collect_referenced_late_bound_regions(&poly_proj_pred)
}
_ => return FxHashSet::default(),
@ -466,7 +466,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
.filter(|p| {
!orig_bounds.contains(p)
|| match p {
ty::Predicate::Trait(pred, _) => pred.def_id() == sized_trait,
ty::PredicateKind::Trait(pred, _) => pred.def_id() == sized_trait,
_ => false,
}
})

View file

@ -481,20 +481,18 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
fn clean(&self, cx: &DocContext<'_>) -> Option<WherePredicate> {
use rustc_middle::ty::Predicate;
match *self {
Predicate::Trait(ref pred, _) => Some(pred.clean(cx)),
Predicate::Subtype(ref pred) => Some(pred.clean(cx)),
Predicate::RegionOutlives(ref pred) => pred.clean(cx),
Predicate::TypeOutlives(ref pred) => pred.clean(cx),
Predicate::Projection(ref pred) => Some(pred.clean(cx)),
ty::PredicateKind::Trait(ref pred, _) => Some(pred.clean(cx)),
ty::PredicateKind::Subtype(ref pred) => Some(pred.clean(cx)),
ty::PredicateKind::RegionOutlives(ref pred) => pred.clean(cx),
ty::PredicateKind::TypeOutlives(ref pred) => pred.clean(cx),
ty::PredicateKind::Projection(ref pred) => Some(pred.clean(cx)),
Predicate::WellFormed(..)
| Predicate::ObjectSafe(..)
| Predicate::ClosureKind(..)
| Predicate::ConstEvaluatable(..)
| Predicate::ConstEquate(..) => panic!("not user writable"),
ty::PredicateKind::WellFormed(..)
| ty::PredicateKind::ObjectSafe(..)
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..) => panic!("not user writable"),
}
}
}
@ -765,7 +763,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
if let ty::Param(param) = outlives.skip_binder().0.kind {
return Some(param.index);
}
} else if let ty::Predicate::Projection(p) = p {
} else if let ty::PredicateKind::Projection(p) = p {
if let ty::Param(param) = p.skip_binder().projection_ty.self_ty().kind {
projection = Some(p);
return Some(param.index);
@ -1663,7 +1661,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
.filter_map(|predicate| {
let trait_ref = if let Some(tr) = predicate.to_opt_poly_trait_ref() {
tr
} else if let ty::Predicate::TypeOutlives(pred) = *predicate {
} else if let ty::PredicateKind::TypeOutlives(pred) = *predicate {
// these should turn up at the end
if let Some(r) = pred.skip_binder().1.clean(cx) {
regions.push(GenericBound::Outlives(r));
@ -1684,7 +1682,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
.predicates
.iter()
.filter_map(|pred| {
if let ty::Predicate::Projection(proj) = *pred {
if let ty::PredicateKind::Projection(proj) = *pred {
let proj = proj.skip_binder();
if proj.projection_ty.trait_ref(cx.tcx)
== *trait_ref.skip_binder()

View file

@ -141,7 +141,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
.predicates
.iter()
.filter_map(|(pred, _)| {
if let ty::Predicate::Trait(ref pred, _) = *pred {
if let ty::PredicateKind::Trait(ref pred, _) = *pred {
if pred.skip_binder().trait_ref.self_ty() == self_ty {
Some(pred.def_id())
} else {

View file

@ -3,7 +3,7 @@ use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, FnDecl, HirId};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{Opaque, Predicate::Trait, ToPolyTraitRef};
use rustc_middle::ty::{Opaque, PredicateKind::Trait, ToPolyTraitRef};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{sym, Span};
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;

View file

@ -18,7 +18,7 @@ use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
use rustc_middle::hir::map::Map;
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, Predicate, Ty};
use rustc_middle::ty::{self, Ty};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use rustc_span::symbol::{sym, SymbolStr};
@ -1497,7 +1497,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
// one of the associated types must be Self
for predicate in cx.tcx.predicates_of(def_id).predicates {
match predicate {
(Predicate::Projection(poly_projection_predicate), _) => {
(ty::PredicateKind::Projection(poly_projection_predicate), _) => {
let binder = poly_projection_predicate.ty();
let associated_type = binder.skip_binder();

View file

@ -114,7 +114,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.iter().copied())
.filter(|p| !p.is_global())
.filter_map(|obligation| {
if let ty::Predicate::Trait(poly_trait_ref, _) = obligation.predicate {
if let ty::PredicateKind::Trait(poly_trait_ref, _) = obligation.predicate {
if poly_trait_ref.def_id() == sized_trait || poly_trait_ref.skip_binder().has_escaping_bound_vars()
{
return None;

View file

@ -1299,7 +1299,7 @@ pub fn is_must_use_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> boo
ty::Tuple(ref substs) => substs.types().any(|ty| is_must_use_ty(cx, ty)),
ty::Opaque(ref def_id, _) => {
for (predicate, _) in cx.tcx.predicates_of(*def_id).predicates {
if let ty::Predicate::Trait(ref poly_trait_predicate, _) = predicate {
if let ty::PredicateKind::Trait(ref poly_trait_predicate, _) = predicate {
if must_use_attr(&cx.tcx.get_attrs(poly_trait_predicate.skip_binder().trait_ref.def_id)).is_some() {
return true;
}