Remove PredicateS type
This commit is contained in:
parent
46ba1545b8
commit
907ef227ef
@ -91,7 +91,7 @@ macro_rules! arena_types {
|
||||
|
||||
// Interned types
|
||||
[] tys: rustc_type_ir::WithCachedTypeInfo<rustc_middle::ty::TyKind<'tcx>>,
|
||||
[] predicates: rustc_type_ir::WithCachedTypeInfo<rustc_middle::ty::PredicateS<'tcx>>,
|
||||
[] predicates: rustc_type_ir::WithCachedTypeInfo<rustc_middle::ty::PredicateKind<'tcx>>,
|
||||
[] consts: rustc_middle::ty::ConstS<'tcx>,
|
||||
|
||||
// Note that this deliberately duplicates items in the `rustc_hir::arena`,
|
||||
|
@ -21,9 +21,9 @@
|
||||
self, AdtDef, AdtDefData, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig,
|
||||
ClosureSizeProfileData, Const, ConstS, DefIdTree, FloatTy, FloatVar, FloatVid,
|
||||
GenericParamDefKind, InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy,
|
||||
PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, PredicateS, ProjectionTy,
|
||||
Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut,
|
||||
UintTy, Visibility,
|
||||
PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, ProjectionTy, Region,
|
||||
RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVar, TyVid, TypeAndMut, UintTy,
|
||||
Visibility,
|
||||
};
|
||||
use crate::ty::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef, UserSubsts};
|
||||
use rustc_ast as ast;
|
||||
@ -145,7 +145,7 @@ pub struct CtxtInterners<'tcx> {
|
||||
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
|
||||
region: InternedSet<'tcx, RegionKind<'tcx>>,
|
||||
poly_existential_predicates: InternedSet<'tcx, List<PolyExistentialPredicate<'tcx>>>,
|
||||
predicate: InternedSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>,
|
||||
predicate: InternedSet<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
|
||||
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
|
||||
projs: InternedSet<'tcx, List<ProjectionKind>>,
|
||||
place_elems: InternedSet<'tcx, List<PlaceElem<'tcx>>>,
|
||||
@ -245,16 +245,12 @@ fn intern_predicate(
|
||||
let stable_hash =
|
||||
self.stable_hash(&flags, sess, definitions, cstore, source_span, &kind);
|
||||
|
||||
let predicate_struct = PredicateS {
|
||||
kind,
|
||||
InternedInSet(self.arena.alloc(WithCachedTypeInfo {
|
||||
internee: kind,
|
||||
stable_hash,
|
||||
flags: flags.flags,
|
||||
outer_exclusive_binder: flags.outer_exclusive_binder,
|
||||
};
|
||||
|
||||
InternedInSet(
|
||||
self.arena
|
||||
.alloc(WithCachedTypeInfo { internee: predicate_struct, stable_hash }),
|
||||
)
|
||||
}))
|
||||
})
|
||||
.0,
|
||||
))
|
||||
@ -2191,27 +2187,32 @@ fn hash<H: Hasher>(&self, s: &mut H) {
|
||||
}
|
||||
|
||||
impl<'tcx> Borrow<Binder<'tcx, PredicateKind<'tcx>>>
|
||||
for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>
|
||||
for InternedInSet<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>
|
||||
{
|
||||
fn borrow<'a>(&'a self) -> &'a Binder<'tcx, PredicateKind<'tcx>> {
|
||||
&self.0.kind
|
||||
&self.0.internee
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PartialEq for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>> {
|
||||
fn eq(&self, other: &InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>) -> bool {
|
||||
impl<'tcx> PartialEq
|
||||
for InternedInSet<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>
|
||||
{
|
||||
fn eq(
|
||||
&self,
|
||||
other: &InternedInSet<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
|
||||
) -> bool {
|
||||
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
|
||||
// `x == y`.
|
||||
self.0.kind == other.0.kind
|
||||
self.0.internee == other.0.internee
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Eq for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>> {}
|
||||
impl<'tcx> Eq for InternedInSet<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>> {}
|
||||
|
||||
impl<'tcx> Hash for InternedInSet<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>> {
|
||||
impl<'tcx> Hash for InternedInSet<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>> {
|
||||
fn hash<H: Hasher>(&self, s: &mut H) {
|
||||
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
|
||||
self.0.kind.hash(s)
|
||||
self.0.internee.hash(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,28 +474,18 @@ pub fn has_name(&self) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents a predicate.
|
||||
///
|
||||
/// See comments on `WithCachedTypeInfo`, which apply here too (albeit for
|
||||
/// `PredicateS`/`Predicate` rather than `TyKind`/`Ty`).
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct PredicateS<'tcx> {
|
||||
kind: Binder<'tcx, PredicateKind<'tcx>>,
|
||||
flags: TypeFlags,
|
||||
/// See the comment for the corresponding field of [WithCachedTypeInfo].
|
||||
outer_exclusive_binder: ty::DebruijnIndex,
|
||||
}
|
||||
|
||||
/// Use this rather than `PredicateS`, whenever possible.
|
||||
/// Use this rather than `PredicateKind`, whenever possible.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable)]
|
||||
#[rustc_pass_by_value]
|
||||
pub struct Predicate<'tcx>(Interned<'tcx, WithCachedTypeInfo<PredicateS<'tcx>>>);
|
||||
pub struct Predicate<'tcx>(
|
||||
Interned<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
|
||||
);
|
||||
|
||||
impl<'tcx> Predicate<'tcx> {
|
||||
/// Gets the inner `Binder<'tcx, PredicateKind<'tcx>>`.
|
||||
#[inline]
|
||||
pub fn kind(self) -> Binder<'tcx, PredicateKind<'tcx>> {
|
||||
self.0.kind
|
||||
self.0.internee
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@ -570,21 +560,6 @@ pub fn allow_normalization(self) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for PredicateS<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let PredicateS {
|
||||
ref kind,
|
||||
|
||||
// The other fields just provide fast access to information that is
|
||||
// also contained in `kind`, so no need to hash them.
|
||||
flags: _,
|
||||
outer_exclusive_binder: _,
|
||||
} = self;
|
||||
|
||||
kind.hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
|
||||
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
|
||||
rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string()))
|
||||
@ -2631,7 +2606,7 @@ mod size_asserts {
|
||||
use super::*;
|
||||
use rustc_data_structures::static_assert_size;
|
||||
// tidy-alphabetical-start
|
||||
static_assert_size!(PredicateS<'_>, 48);
|
||||
static_assert_size!(PredicateKind<'_>, 32);
|
||||
static_assert_size!(WithCachedTypeInfo<TyKind<'_>>, 56);
|
||||
// tidy-alphabetical-end
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user