Rollup merge of #99900 - lcnr:hash-stable-fun, r=cjgillot
remove some manual hash stable impls
This commit is contained in:
commit
79c947443f
5 changed files with 15 additions and 89 deletions
|
@ -3,6 +3,7 @@ use rustc_index::bit_set;
|
||||||
use rustc_index::vec;
|
use rustc_index::vec;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::hash::{BuildHasher, Hash, Hasher};
|
use std::hash::{BuildHasher, Hash, Hasher};
|
||||||
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -261,6 +262,10 @@ impl<CTX> HashStable<CTX> for ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<CTX, T> HashStable<CTX> for PhantomData<T> {
|
||||||
|
fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) {}
|
||||||
|
}
|
||||||
|
|
||||||
impl<CTX> HashStable<CTX> for ::std::num::NonZeroU32 {
|
impl<CTX> HashStable<CTX> for ::std::num::NonZeroU32 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
|
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
|
||||||
|
|
|
@ -9,13 +9,9 @@ use crate::infer::canonical::{Canonical, QueryResponse};
|
||||||
use crate::ty::error::TypeError;
|
use crate::ty::error::TypeError;
|
||||||
use crate::ty::subst::GenericArg;
|
use crate::ty::subst::GenericArg;
|
||||||
use crate::ty::{self, Ty, TyCtxt};
|
use crate::ty::{self, Ty, TyCtxt};
|
||||||
|
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_err;
|
||||||
use rustc_query_system::ich::StableHashingContext;
|
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
pub mod type_op {
|
pub mod type_op {
|
||||||
use crate::ty::fold::TypeFoldable;
|
use crate::ty::fold::TypeFoldable;
|
||||||
|
@ -226,29 +222,9 @@ pub struct NormalizationResult<'tcx> {
|
||||||
/// case they are called implied bounds). They are fed to the
|
/// case they are called implied bounds). They are fed to the
|
||||||
/// `OutlivesEnv` which in turn is supplied to the region checker and
|
/// `OutlivesEnv` which in turn is supplied to the region checker and
|
||||||
/// other parts of the inference system.
|
/// other parts of the inference system.
|
||||||
#[derive(Clone, Debug, TypeFoldable, TypeVisitable, Lift)]
|
#[derive(Clone, Debug, TypeFoldable, TypeVisitable, Lift, HashStable)]
|
||||||
pub enum OutlivesBound<'tcx> {
|
pub enum OutlivesBound<'tcx> {
|
||||||
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
|
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
|
||||||
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
|
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
|
||||||
RegionSubProjection(ty::Region<'tcx>, ty::ProjectionTy<'tcx>),
|
RegionSubProjection(ty::Region<'tcx>, ty::ProjectionTy<'tcx>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OutlivesBound<'tcx> {
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
|
||||||
match *self {
|
|
||||||
OutlivesBound::RegionSubRegion(ref a, ref b) => {
|
|
||||||
a.hash_stable(hcx, hasher);
|
|
||||||
b.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
OutlivesBound::RegionSubParam(ref a, ref b) => {
|
|
||||||
a.hash_stable(hcx, hasher);
|
|
||||||
b.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
OutlivesBound::RegionSubProjection(ref a, ref b) => {
|
|
||||||
a.hash_stable(hcx, hasher);
|
|
||||||
b.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -101,46 +101,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArgKin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HashStable<StableHashingContext<'a>> for ty::EarlyBoundRegion {
|
|
||||||
#[inline]
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
self.def_id.hash_stable(hcx, hasher);
|
|
||||||
self.index.hash_stable(hcx, hasher);
|
|
||||||
self.name.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
|
|
||||||
#[inline]
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
self.index().hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::ConstVid<'tcx> {
|
|
||||||
#[inline]
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
self.index.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> HashStable<StableHashingContext<'tcx>> for ty::BoundVar {
|
|
||||||
#[inline]
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
|
|
||||||
self.index().hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<'tcx, T>
|
|
||||||
where
|
|
||||||
T: HashStable<StableHashingContext<'a>>,
|
|
||||||
{
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
self.as_ref().skip_binder().hash_stable(hcx, hasher);
|
|
||||||
self.bound_vars().hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllocIds get resolved to whatever they point to (to be stable)
|
// AllocIds get resolved to whatever they point to (to be stable)
|
||||||
impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
|
impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||||
|
|
|
@ -1182,22 +1182,13 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
|
||||||
/// identified by both a universe, as well as a name residing within that universe. Distinct bound
|
/// identified by both a universe, as well as a name residing within that universe. Distinct bound
|
||||||
/// regions/types/consts within the same universe simply have an unknown relationship to one
|
/// regions/types/consts within the same universe simply have an unknown relationship to one
|
||||||
/// another.
|
/// another.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
|
#[derive(HashStable, TyEncodable, TyDecodable)]
|
||||||
pub struct Placeholder<T> {
|
pub struct Placeholder<T> {
|
||||||
pub universe: UniverseIndex,
|
pub universe: UniverseIndex,
|
||||||
pub name: T,
|
pub name: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
|
|
||||||
where
|
|
||||||
T: HashStable<StableHashingContext<'a>>,
|
|
||||||
{
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
self.universe.hash_stable(hcx, hasher);
|
|
||||||
self.name.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type PlaceholderRegion = Placeholder<BoundRegionKind>;
|
pub type PlaceholderRegion = Placeholder<BoundRegionKind>;
|
||||||
|
|
||||||
pub type PlaceholderType = Placeholder<BoundVar>;
|
pub type PlaceholderType = Placeholder<BoundVar>;
|
||||||
|
@ -1581,6 +1572,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable, TypeVisitable)]
|
||||||
|
#[derive(HashStable)]
|
||||||
pub struct ParamEnvAnd<'tcx, T> {
|
pub struct ParamEnvAnd<'tcx, T> {
|
||||||
pub param_env: ParamEnv<'tcx>,
|
pub param_env: ParamEnv<'tcx>,
|
||||||
pub value: T,
|
pub value: T,
|
||||||
|
@ -1598,18 +1590,6 @@ impl<'tcx, T> ParamEnvAnd<'tcx, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for ParamEnvAnd<'tcx, T>
|
|
||||||
where
|
|
||||||
T: HashStable<StableHashingContext<'a>>,
|
|
||||||
{
|
|
||||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
|
||||||
let ParamEnvAnd { ref param_env, ref value } = *self;
|
|
||||||
|
|
||||||
param_env.hash_stable(hcx, hasher);
|
|
||||||
value.hash_stable(hcx, hasher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
|
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
|
||||||
pub struct Destructor {
|
pub struct Destructor {
|
||||||
/// The `DefId` of the destructor method
|
/// The `DefId` of the destructor method
|
||||||
|
|
|
@ -1009,6 +1009,7 @@ impl BoundVariableKind {
|
||||||
///
|
///
|
||||||
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
|
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
|
#[derive(HashStable)]
|
||||||
pub struct Binder<'tcx, T>(T, &'tcx List<BoundVariableKind>);
|
pub struct Binder<'tcx, T>(T, &'tcx List<BoundVariableKind>);
|
||||||
|
|
||||||
impl<'tcx, T> Binder<'tcx, T>
|
impl<'tcx, T> Binder<'tcx, T>
|
||||||
|
@ -1355,6 +1356,7 @@ impl<'tcx> fmt::Debug for Region<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
|
||||||
|
#[derive(HashStable)]
|
||||||
pub struct EarlyBoundRegion {
|
pub struct EarlyBoundRegion {
|
||||||
pub def_id: DefId,
|
pub def_id: DefId,
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
|
@ -1368,7 +1370,8 @@ impl fmt::Debug for EarlyBoundRegion {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A **`const`** **v**ariable **ID**.
|
/// A **`const`** **v**ariable **ID**.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[derive(HashStable, TyEncodable, TyDecodable)]
|
||||||
pub struct ConstVid<'tcx> {
|
pub struct ConstVid<'tcx> {
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub phantom: PhantomData<&'tcx ()>,
|
pub phantom: PhantomData<&'tcx ()>,
|
||||||
|
@ -1376,6 +1379,7 @@ pub struct ConstVid<'tcx> {
|
||||||
|
|
||||||
rustc_index::newtype_index! {
|
rustc_index::newtype_index! {
|
||||||
/// A **region** (lifetime) **v**ariable **ID**.
|
/// A **region** (lifetime) **v**ariable **ID**.
|
||||||
|
#[derive(HashStable)]
|
||||||
pub struct RegionVid {
|
pub struct RegionVid {
|
||||||
DEBUG_FORMAT = custom,
|
DEBUG_FORMAT = custom,
|
||||||
}
|
}
|
||||||
|
@ -1388,6 +1392,7 @@ impl Atom for RegionVid {
|
||||||
}
|
}
|
||||||
|
|
||||||
rustc_index::newtype_index! {
|
rustc_index::newtype_index! {
|
||||||
|
#[derive(HashStable)]
|
||||||
pub struct BoundVar { .. }
|
pub struct BoundVar { .. }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue