Skip to content

Commit 1dd5133

Browse files
committed
Move impl HashStable for Symbol in libsyntax_pos.
1 parent 05f5f76 commit 1dd5133

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,12 @@ use syntax::ast;
1010
use syntax::feature_gate;
1111
use syntax::token;
1212
use syntax::tokenstream;
13-
use syntax_pos::symbol::SymbolStr;
1413
use syntax_pos::SourceFile;
1514

1615
use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
1716

1817
use smallvec::SmallVec;
19-
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
20-
21-
impl<'a> HashStable<StableHashingContext<'a>> for ast::Name {
22-
#[inline]
23-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
24-
self.as_str().hash_stable(hcx, hasher);
25-
}
26-
}
27-
28-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::Name {
29-
type KeyType = SymbolStr;
30-
31-
#[inline]
32-
fn to_stable_hash_key(&self,
33-
_: &StableHashingContext<'a>)
34-
-> SymbolStr {
35-
self.as_str()
36-
}
37-
}
18+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3819

3920
impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
4021
Bang,

src/libsyntax_pos/symbol.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,22 @@ impl Decodable for Symbol {
940940
}
941941
}
942942

943+
impl<CTX> HashStable<CTX> for Symbol {
944+
#[inline]
945+
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
946+
self.as_str().hash_stable(hcx, hasher);
947+
}
948+
}
949+
950+
impl<CTX> ToStableHashKey<CTX> for Symbol {
951+
type KeyType = SymbolStr;
952+
953+
#[inline]
954+
fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr {
955+
self.as_str()
956+
}
957+
}
958+
943959
// The `&'static str`s in this type actually point into the arena.
944960
#[derive(Default)]
945961
pub struct Interner {

0 commit comments

Comments
 (0)