Skip to content

Commit 05f5f76

Browse files
committed
Move impl HashStable for SymbolStr in libsyntax_pos.
1 parent c2e1658 commit 05f5f76

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,6 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
1818
use smallvec::SmallVec;
1919
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
2020

21-
impl<'a> HashStable<StableHashingContext<'a>> for SymbolStr {
22-
#[inline]
23-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
24-
let str = self as &str;
25-
str.hash_stable(hcx, hasher)
26-
}
27-
}
28-
29-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for SymbolStr {
30-
type KeyType = SymbolStr;
31-
32-
#[inline]
33-
fn to_stable_hash_key(&self,
34-
_: &StableHashingContext<'a>)
35-
-> SymbolStr {
36-
self.clone()
37-
}
38-
}
39-
4021
impl<'a> HashStable<StableHashingContext<'a>> for ast::Name {
4122
#[inline]
4223
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {

src/libsyntax_pos/symbol.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use rustc_index::vec::Idx;
88
use rustc_macros::symbols;
99
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
1010
use rustc_serialize::{UseSpecializedDecodable, UseSpecializedEncodable};
11+
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
1112

1213
use std::cmp::{PartialEq, PartialOrd, Ord};
1314
use std::fmt;
@@ -1136,3 +1137,20 @@ impl fmt::Display for SymbolStr {
11361137
fmt::Display::fmt(self.string, f)
11371138
}
11381139
}
1140+
1141+
impl<CTX> HashStable<CTX> for SymbolStr {
1142+
#[inline]
1143+
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
1144+
let str = self as &str;
1145+
str.hash_stable(hcx, hasher)
1146+
}
1147+
}
1148+
1149+
impl<CTX> ToStableHashKey<CTX> for SymbolStr {
1150+
type KeyType = SymbolStr;
1151+
1152+
#[inline]
1153+
fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr {
1154+
self.clone()
1155+
}
1156+
}

0 commit comments

Comments
 (0)