s/Clause/ClauseKind
This commit is contained in:
@@ -487,11 +487,11 @@ impl<'tcx> Predicate<'tcx> {
|
||||
let kind = self
|
||||
.kind()
|
||||
.map_bound(|kind| match kind {
|
||||
PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||
PredicateKind::Clause(ClauseKind::Trait(TraitPredicate {
|
||||
trait_ref,
|
||||
constness,
|
||||
polarity,
|
||||
})) => Some(PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||
})) => Some(PredicateKind::Clause(ClauseKind::Trait(TraitPredicate {
|
||||
trait_ref,
|
||||
constness,
|
||||
polarity: polarity.flip()?,
|
||||
@@ -505,10 +505,10 @@ impl<'tcx> Predicate<'tcx> {
|
||||
}
|
||||
|
||||
pub fn without_const(mut self, tcx: TyCtxt<'tcx>) -> Self {
|
||||
if let PredicateKind::Clause(Clause::Trait(TraitPredicate { trait_ref, constness, polarity })) = self.kind().skip_binder()
|
||||
if let PredicateKind::Clause(ClauseKind::Trait(TraitPredicate { trait_ref, constness, polarity })) = self.kind().skip_binder()
|
||||
&& constness != BoundConstness::NotConst
|
||||
{
|
||||
self = tcx.mk_predicate(self.kind().rebind(PredicateKind::Clause(Clause::Trait(TraitPredicate {
|
||||
self = tcx.mk_predicate(self.kind().rebind(PredicateKind::Clause(ClauseKind::Trait(TraitPredicate {
|
||||
trait_ref,
|
||||
constness: BoundConstness::NotConst,
|
||||
polarity,
|
||||
@@ -520,10 +520,10 @@ impl<'tcx> Predicate<'tcx> {
|
||||
#[instrument(level = "debug", skip(tcx), ret)]
|
||||
pub fn is_coinductive(self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
match self.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(data)) => {
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::Trait(data)) => {
|
||||
tcx.trait_is_coinductive(data.def_id())
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::WellFormed(_)) => true,
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -536,18 +536,18 @@ impl<'tcx> Predicate<'tcx> {
|
||||
#[inline]
|
||||
pub fn allow_normalization(self) -> bool {
|
||||
match self.kind().skip_binder() {
|
||||
PredicateKind::Clause(Clause::WellFormed(_)) => false,
|
||||
PredicateKind::Clause(Clause::Trait(_))
|
||||
| PredicateKind::Clause(Clause::RegionOutlives(_))
|
||||
| PredicateKind::Clause(Clause::TypeOutlives(_))
|
||||
| PredicateKind::Clause(Clause::Projection(_))
|
||||
| PredicateKind::Clause(Clause::ConstArgHasType(..))
|
||||
PredicateKind::Clause(ClauseKind::WellFormed(_)) => false,
|
||||
PredicateKind::Clause(ClauseKind::Trait(_))
|
||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(_))
|
||||
| PredicateKind::Clause(ClauseKind::TypeOutlives(_))
|
||||
| PredicateKind::Clause(ClauseKind::Projection(_))
|
||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||
| PredicateKind::AliasRelate(..)
|
||||
| PredicateKind::ObjectSafe(_)
|
||||
| PredicateKind::ClosureKind(_, _, _)
|
||||
| PredicateKind::Subtype(_)
|
||||
| PredicateKind::Coerce(_)
|
||||
| PredicateKind::Clause(Clause::ConstEvaluatable(_))
|
||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
|
||||
| PredicateKind::ConstEquate(_, _)
|
||||
| PredicateKind::Ambiguous
|
||||
| PredicateKind::TypeWellFormedFromEnv(_) => true,
|
||||
@@ -565,7 +565,7 @@ impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||
/// A clause is something that can appear in where bounds or be inferred
|
||||
/// by implied bounds.
|
||||
pub enum Clause<'tcx> {
|
||||
pub enum ClauseKind<'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.
|
||||
@@ -592,9 +592,9 @@ pub enum Clause<'tcx> {
|
||||
ConstEvaluatable(ty::Const<'tcx>),
|
||||
}
|
||||
|
||||
impl<'tcx> Binder<'tcx, Clause<'tcx>> {
|
||||
impl<'tcx> Binder<'tcx, ClauseKind<'tcx>> {
|
||||
pub fn as_trait_clause(self) -> Option<Binder<'tcx, TraitPredicate<'tcx>>> {
|
||||
if let ty::Clause::Trait(trait_clause) = self.skip_binder() {
|
||||
if let ty::ClauseKind::Trait(trait_clause) = self.skip_binder() {
|
||||
Some(self.rebind(trait_clause))
|
||||
} else {
|
||||
None
|
||||
@@ -602,7 +602,7 @@ impl<'tcx> Binder<'tcx, Clause<'tcx>> {
|
||||
}
|
||||
|
||||
pub fn as_projection_clause(self) -> Option<Binder<'tcx, ProjectionPredicate<'tcx>>> {
|
||||
if let ty::Clause::Projection(projection_clause) = self.skip_binder() {
|
||||
if let ty::ClauseKind::Projection(projection_clause) = self.skip_binder() {
|
||||
Some(self.rebind(projection_clause))
|
||||
} else {
|
||||
None
|
||||
@@ -614,7 +614,7 @@ impl<'tcx> Binder<'tcx, Clause<'tcx>> {
|
||||
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
|
||||
pub enum PredicateKind<'tcx> {
|
||||
/// Prove a clause
|
||||
Clause(Clause<'tcx>),
|
||||
Clause(ClauseKind<'tcx>),
|
||||
|
||||
/// Trait must be object-safe.
|
||||
ObjectSafe(DefId),
|
||||
@@ -653,7 +653,7 @@ pub enum PredicateKind<'tcx> {
|
||||
/// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
|
||||
Ambiguous,
|
||||
|
||||
/// Separate from `Clause::Projection` which is used for normalization in new solver.
|
||||
/// Separate from `ClauseKind::Projection` which is used for normalization in new solver.
|
||||
/// This predicate requires two terms to be equal to eachother.
|
||||
///
|
||||
/// Only used for new solver
|
||||
@@ -687,7 +687,8 @@ pub struct CratePredicatesMap<'tcx> {
|
||||
/// For each struct with outlive bounds, maps to a vector of the
|
||||
/// predicate of its outlive bounds. If an item has no outlives
|
||||
/// bounds, it will have no entry.
|
||||
pub predicates: FxHashMap<DefId, &'tcx [(Clause<'tcx>, Span)]>,
|
||||
// FIXME(clause): should this be a `Clause`?
|
||||
pub predicates: FxHashMap<DefId, &'tcx [(ClauseKind<'tcx>, Span)]>,
|
||||
}
|
||||
|
||||
impl<'tcx> Predicate<'tcx> {
|
||||
@@ -1207,14 +1208,14 @@ impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for Clause<'tcx> {
|
||||
impl<'tcx> ToPredicate<'tcx> for ClauseKind<'tcx> {
|
||||
#[inline(always)]
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
tcx.mk_predicate(ty::Binder::dummy(ty::PredicateKind::Clause(self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, Clause<'tcx>> {
|
||||
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, ClauseKind<'tcx>> {
|
||||
#[inline(always)]
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
tcx.mk_predicate(self.map_bound(|clause| ty::PredicateKind::Clause(clause)))
|
||||
@@ -1228,10 +1229,10 @@ impl<'tcx> ToPredicate<'tcx> for TraitRef<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for TraitRef<'tcx> {
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, ClauseKind<'tcx>>> for TraitRef<'tcx> {
|
||||
#[inline(always)]
|
||||
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
|
||||
Binder::dummy(Clause::Trait(TraitPredicate {
|
||||
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, ClauseKind<'tcx>> {
|
||||
Binder::dummy(ClauseKind::Trait(TraitPredicate {
|
||||
trait_ref: self,
|
||||
constness: ty::BoundConstness::NotConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
@@ -1247,9 +1248,9 @@ impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for Binder<'tcx, TraitRef<'tcx>> {
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, ClauseKind<'tcx>>> for Binder<'tcx, TraitRef<'tcx>> {
|
||||
#[inline(always)]
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Binder<'tcx, ClauseKind<'tcx>> {
|
||||
let pred: PolyTraitPredicate<'tcx> = self.to_predicate(tcx);
|
||||
pred.to_predicate(tcx)
|
||||
}
|
||||
@@ -1280,43 +1281,43 @@ impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for TraitPredicate<'tcx>
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(|p| PredicateKind::Clause(Clause::Trait(p))).to_predicate(tcx)
|
||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for PolyTraitPredicate<'tcx> {
|
||||
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
|
||||
self.map_bound(|p| Clause::Trait(p))
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, ClauseKind<'tcx>>> for PolyTraitPredicate<'tcx> {
|
||||
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, ClauseKind<'tcx>> {
|
||||
self.map_bound(|p| ClauseKind::Trait(p))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(|p| PredicateKind::Clause(Clause::RegionOutlives(p))).to_predicate(tcx)
|
||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::RegionOutlives(p))).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(|p| PredicateKind::Clause(Clause::TypeOutlives(p))).to_predicate(tcx)
|
||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::TypeOutlives(p))).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
self.map_bound(|p| PredicateKind::Clause(Clause::Projection(p))).to_predicate(tcx)
|
||||
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, Clause<'tcx>>> for PolyProjectionPredicate<'tcx> {
|
||||
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, Clause<'tcx>> {
|
||||
self.map_bound(|p| Clause::Projection(p))
|
||||
impl<'tcx> ToPredicate<'tcx, Binder<'tcx, ClauseKind<'tcx>>> for PolyProjectionPredicate<'tcx> {
|
||||
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> Binder<'tcx, ClauseKind<'tcx>> {
|
||||
self.map_bound(|p| ClauseKind::Projection(p))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
|
||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||
PredicateKind::Clause(Clause::Trait(self)).to_predicate(tcx)
|
||||
PredicateKind::Clause(ClauseKind::Trait(self)).to_predicate(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1324,18 +1325,18 @@ impl<'tcx> Predicate<'tcx> {
|
||||
pub fn to_opt_poly_trait_pred(self) -> Option<PolyTraitPredicate<'tcx>> {
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateKind::Clause(Clause::Trait(t)) => Some(predicate.rebind(t)),
|
||||
PredicateKind::Clause(Clause::Projection(..))
|
||||
| PredicateKind::Clause(Clause::ConstArgHasType(..))
|
||||
PredicateKind::Clause(ClauseKind::Trait(t)) => Some(predicate.rebind(t)),
|
||||
PredicateKind::Clause(ClauseKind::Projection(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||
| PredicateKind::AliasRelate(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::Coerce(..)
|
||||
| PredicateKind::Clause(Clause::RegionOutlives(..))
|
||||
| PredicateKind::Clause(Clause::WellFormed(..))
|
||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::ClosureKind(..)
|
||||
| PredicateKind::Clause(Clause::TypeOutlives(..))
|
||||
| PredicateKind::Clause(Clause::ConstEvaluatable(..))
|
||||
| PredicateKind::Clause(ClauseKind::TypeOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::Ambiguous
|
||||
| PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
@@ -1345,18 +1346,18 @@ impl<'tcx> Predicate<'tcx> {
|
||||
pub fn to_opt_poly_projection_pred(self) -> Option<PolyProjectionPredicate<'tcx>> {
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateKind::Clause(Clause::Projection(t)) => Some(predicate.rebind(t)),
|
||||
PredicateKind::Clause(Clause::Trait(..))
|
||||
| PredicateKind::Clause(Clause::ConstArgHasType(..))
|
||||
PredicateKind::Clause(ClauseKind::Projection(t)) => Some(predicate.rebind(t)),
|
||||
PredicateKind::Clause(ClauseKind::Trait(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||
| PredicateKind::AliasRelate(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::Coerce(..)
|
||||
| PredicateKind::Clause(Clause::RegionOutlives(..))
|
||||
| PredicateKind::Clause(Clause::WellFormed(..))
|
||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::ClosureKind(..)
|
||||
| PredicateKind::Clause(Clause::TypeOutlives(..))
|
||||
| PredicateKind::Clause(Clause::ConstEvaluatable(..))
|
||||
| PredicateKind::Clause(ClauseKind::TypeOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::Ambiguous
|
||||
| PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
@@ -1366,25 +1367,25 @@ impl<'tcx> Predicate<'tcx> {
|
||||
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateKind::Clause(Clause::TypeOutlives(data)) => Some(predicate.rebind(data)),
|
||||
PredicateKind::Clause(Clause::Trait(..))
|
||||
| PredicateKind::Clause(Clause::ConstArgHasType(..))
|
||||
| PredicateKind::Clause(Clause::Projection(..))
|
||||
PredicateKind::Clause(ClauseKind::TypeOutlives(data)) => Some(predicate.rebind(data)),
|
||||
PredicateKind::Clause(ClauseKind::Trait(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
|
||||
| PredicateKind::Clause(ClauseKind::Projection(..))
|
||||
| PredicateKind::AliasRelate(..)
|
||||
| PredicateKind::Subtype(..)
|
||||
| PredicateKind::Coerce(..)
|
||||
| PredicateKind::Clause(Clause::RegionOutlives(..))
|
||||
| PredicateKind::Clause(Clause::WellFormed(..))
|
||||
| PredicateKind::Clause(ClauseKind::RegionOutlives(..))
|
||||
| PredicateKind::Clause(ClauseKind::WellFormed(..))
|
||||
| PredicateKind::ObjectSafe(..)
|
||||
| PredicateKind::ClosureKind(..)
|
||||
| PredicateKind::Clause(Clause::ConstEvaluatable(..))
|
||||
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
|
||||
| PredicateKind::ConstEquate(..)
|
||||
| PredicateKind::Ambiguous
|
||||
| PredicateKind::TypeWellFormedFromEnv(..) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_clause(self) -> Option<Binder<'tcx, Clause<'tcx>>> {
|
||||
pub fn as_clause(self) -> Option<Binder<'tcx, ClauseKind<'tcx>>> {
|
||||
let predicate = self.kind();
|
||||
match predicate.skip_binder() {
|
||||
PredicateKind::Clause(clause) => Some(predicate.rebind(clause)),
|
||||
|
||||
Reference in New Issue
Block a user