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.
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,
self.obligations.push(Obligation::new(
self.trace.cause.clone(),
self.param_env,
- ty::Predicate::WellFormed(b_ty),
+ ty::PredicateKind::WellFormed(b_ty),
));
}
) -> 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)),
})
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,
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),
}
}
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());
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
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),
)))
}
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),
)))
}
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());
}
}
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);
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),
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)
}
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 =
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)?))
})
}
}
+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.
}
}
-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
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))
}
}
}
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,
)
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,
)
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,
}
}
}
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"))
}
}
-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),
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::PredicateKind::Subtype(ref binder) => {
+ tcx.lift(binder).map(ty::PredicateKind::Subtype)
}
- 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::RegionOutlives(ref binder) => {
+ tcx.lift(binder).map(ty::PredicateKind::RegionOutlives)
}
- ty::Predicate::TypeOutlives(ref binder) => {
- tcx.lift(binder).map(ty::Predicate::TypeOutlives)
+ ty::PredicateKind::TypeOutlives(ref binder) => {
+ tcx.lift(binder).map(ty::PredicateKind::TypeOutlives)
}
- ty::Predicate::Projection(ref binder) => {
- tcx.lift(binder).map(ty::Predicate::Projection)
+ ty::PredicateKind::Projection(ref binder) => {
+ tcx.lift(binder).map(ty::PredicateKind::Projection)
}
- ty::Predicate::WellFormed(ty) => tcx.lift(&ty).map(ty::Predicate::WellFormed),
- ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
+ ty::PredicateKind::WellFormed(ty) => tcx.lift(&ty).map(ty::PredicateKind::WellFormed),
+ ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
tcx.lift(&closure_substs).map(|closure_substs| {
- ty::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))
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 =
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()
{
}
self.prove_predicate(
- ty::Predicate::WellFormed(inferred_ty),
+ ty::PredicateKind::WellFormed(inferred_ty),
Locations::All(span),
ConstraintCategory::TypeAnnotation,
);
obligations.obligations.push(traits::Obligation::new(
ObligationCause::dummy(),
param_env,
- ty::Predicate::WellFormed(revealed_ty),
+ ty::PredicateKind::WellFormed(revealed_ty),
));
obligations.add(
infcx
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,
);
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(
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,
)),
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;
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;
}
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) {
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),
}
}
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;
.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
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 {
) {
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;
// 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
}
predicates.push_back(p);
}
- &ty::Predicate::Projection(p) => {
+ &ty::PredicateKind::Projection(p) => {
debug!(
"evaluate_nested_obligations: examining projection predicate {:?}",
predicate
}
}
}
- &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(),
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() {
trait_pred
});
let unit_obligation = Obligation {
- predicate: ty::Predicate::Trait(
+ predicate: ty::PredicateKind::Trait(
predicate,
hir::Constness::NotConst,
),
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)
)
}
- 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,
)
}
- 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(
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
}
}
- ty::Predicate::ConstEvaluatable(..) => {
+ ty::PredicateKind::ConstEvaluatable(..) => {
// Errors for `ConstEvaluatable` predicates show up as
// `SelectionError::ConstEvalFailure`,
// not `Unimplemented`.
}
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;
};
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.
//
// 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,
}
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);
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() {
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;
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;
obligation: &PredicateObligation<'tcx>,
) {
if let (
- ty::Predicate::Trait(pred, _),
+ ty::PredicateKind::Trait(pred, _),
ObligationCauseCode::BindingObligation(item_def_id, span),
) = (&obligation.predicate, &obligation.cause.code)
{
// 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),
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() {
}
}
- 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.
}
}
- 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) => {
}
}
- 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 {
}
}
- 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) {
}
}
- ty::Predicate::WellFormed(ty) => {
+ ty::PredicateKind::WellFormed(ty) => {
match wf::obligations(
self.selcx.infcx(),
obligation.param_env,
}
}
- ty::Predicate::Subtype(ref subtype) => {
+ ty::PredicateKind::Subtype(ref subtype) => {
match self.selcx.infcx().subtype_predicate(
&obligation.cause,
obligation.param_env,
}
}
- ty::Predicate::ConstEvaluatable(def_id, substs) => {
+ ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
match self.selcx.infcx().const_eval_resolve(
obligation.param_env,
def_id,
// 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();
.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)
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
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()
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,
})
}
// 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`. =)
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
// 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 {
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;
// `&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) {
}
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, .. })) => {
}
}
- ty::Predicate::WellFormed(ty) => match wf::obligations(
+ ty::PredicateKind::WellFormed(ty) => match wf::obligations(
self.infcx,
obligation.param_env,
obligation.cause.body_id,
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 {
}
}
- 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)) => {
}
}
- 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) {
}
}
- ty::Predicate::ConstEvaluatable(def_id, substs) => {
+ ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
match self.tcx().const_eval_resolve(
obligation.param_env,
def_id,
// 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);
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);
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),
));
}
// (*) 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);
_ => 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`.
}
}
}
- 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);
}
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))
+ },
));
}
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));
}
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),
+ )),
));
}
}
traits::Obligation::new(
cause.clone(),
param_env,
- ty::Predicate::ObjectSafe(did),
+ ty::PredicateKind::ObjectSafe(did),
)
}));
}
self.out.push(traits::Obligation::new(
cause,
param_env,
- ty::Predicate::WellFormed(ty),
+ ty::PredicateKind::WellFormed(ty),
));
} else {
// Yes, resolved, proceed with the result.
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);
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,
}
}
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;
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
// 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(())
}
}
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()
.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 =
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)
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,
))),
// 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
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 {
.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`
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,
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()
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 };
// 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| {
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 {
};
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);
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();
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
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() {
entry.push(trait_predicate.skip_binder().def_id());
}
}
- ty::Predicate::Projection(projection_pred) => {
+ ty::PredicateKind::Projection(projection_pred) => {
projections.push(projection_pred);
}
_ => {}
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`.
self.register_predicate(traits::Obligation::new(
cause,
self.param_env,
- ty::Predicate::ConstEvaluatable(def_id, substs),
+ ty::PredicateKind::ConstEvaluatable(def_id, substs),
));
}
self.register_predicate(traits::Obligation::new(
cause,
self.param_env,
- ty::Predicate::WellFormed(ty),
+ ty::PredicateKind::WellFormed(ty),
));
}
.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
// 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))
}
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
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
};
let predicate =
- ty::Predicate::Projection(ty::Binder::bind(ty::ProjectionPredicate {
+ ty::PredicateKind::Projection(ty::Binder::bind(ty::ProjectionPredicate {
projection_ty,
ty: expected,
}));
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),
));
}
}
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,
}),
);
// 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());
}
}
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,
));
}
&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))
}
}
}
};
let pred = ty::Binder::bind(ty::OutlivesPredicate(r1, r2));
- (ty::Predicate::RegionOutlives(pred), span)
+ (ty::PredicateKind::RegionOutlives(pred), span)
}))
}
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)]
}
}
}
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();
// 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;
_ 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)
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,
}
}
// 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,
)
}
- ty::Predicate::RegionOutlives(predicate) => {
+ ty::PredicateKind::RegionOutlives(predicate) => {
let OutlivesPredicate(ref reg1, ref reg2) = predicate.skip_binder();
insert_outlives_predicate(
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(..) => (),
}
}
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();
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,
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(),
.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,
}
})
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"),
}
}
}
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);
.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));
.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()
.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 {
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;
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};
// 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();
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;
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;
}