Skip to content

Commit b66dfaa

Browse files
committed
Move some HashStable impls.
1 parent c24c906 commit b66dfaa

File tree

3 files changed

+22
-44
lines changed

3 files changed

+22
-44
lines changed

compiler/rustc_attr/src/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
6666
}
6767
}
6868

69-
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug)]
69+
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
7070
pub enum InlineAttr {
7171
None,
7272
Hint,
7373
Always,
7474
Never,
7575
}
7676

77-
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
77+
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
7878
pub enum InstructionSetAttr {
7979
ArmA32,
8080
ArmT32,
8181
}
8282

83-
#[derive(Clone, Encodable, Decodable, Debug)]
83+
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
8484
pub enum OptimizeAttr {
8585
None,
8686
Speed,

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for HirId {
3333
}
3434
}
3535

36+
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ItemLocalId {
37+
type KeyType = ItemLocalId;
38+
39+
#[inline]
40+
fn to_stable_hash_key(&self, _: &HirCtx) -> ItemLocalId {
41+
*self
42+
}
43+
}
44+
45+
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for BodyId {
46+
type KeyType = (DefPathHash, ItemLocalId);
47+
48+
#[inline]
49+
fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) {
50+
let BodyId { hir_id } = *self;
51+
hir_id.to_stable_hash_key(hcx)
52+
}
53+
}
54+
3655
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ItemId {
3756
type KeyType = DefPathHash;
3857

compiler/rustc_middle/src/ich/impls_hir.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//! types in no particular order.
33
44
use crate::ich::{NodeIdHashingMode, StableHashingContext};
5-
use rustc_attr as attr;
65
use rustc_data_structures::fingerprint::Fingerprint;
76
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
87
use rustc_hir as hir;
@@ -114,15 +113,6 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
114113
}
115114
}
116115

117-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::ItemLocalId {
118-
type KeyType = hir::ItemLocalId;
119-
120-
#[inline]
121-
fn to_stable_hash_key(&self, _: &StableHashingContext<'a>) -> hir::ItemLocalId {
122-
*self
123-
}
124-
}
125-
126116
impl<'a> HashStable<StableHashingContext<'a>> for hir::Body<'_> {
127117
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
128118
let hir::Body { params, value, generator_kind } = self;
@@ -135,19 +125,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Body<'_> {
135125
}
136126
}
137127

138-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::BodyId {
139-
type KeyType = (DefPathHash, hir::ItemLocalId);
140-
141-
#[inline]
142-
fn to_stable_hash_key(
143-
&self,
144-
hcx: &StableHashingContext<'a>,
145-
) -> (DefPathHash, hir::ItemLocalId) {
146-
let hir::BodyId { hir_id } = *self;
147-
hir_id.to_stable_hash_key(hcx)
148-
}
149-
}
150-
151128
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
152129
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
153130
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
@@ -171,21 +148,3 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::TraitCandidate {
171148
)
172149
}
173150
}
174-
175-
impl<'hir> HashStable<StableHashingContext<'hir>> for attr::InlineAttr {
176-
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
177-
mem::discriminant(self).hash_stable(hcx, hasher);
178-
}
179-
}
180-
181-
impl<'hir> HashStable<StableHashingContext<'hir>> for attr::InstructionSetAttr {
182-
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
183-
mem::discriminant(self).hash_stable(hcx, hasher);
184-
}
185-
}
186-
187-
impl<'hir> HashStable<StableHashingContext<'hir>> for attr::OptimizeAttr {
188-
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
189-
mem::discriminant(self).hash_stable(hcx, hasher);
190-
}
191-
}

0 commit comments

Comments
 (0)