Move impl HashStable for SymbolStr in libsyntax_pos.
This commit is contained in:
parent
c2e1658c67
commit
05f5f76b3b
2 changed files with 18 additions and 19 deletions
|
@ -18,25 +18,6 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
|
|||
use smallvec::SmallVec;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for SymbolStr {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let str = self as &str;
|
||||
str.hash_stable(hcx, hasher)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for SymbolStr {
|
||||
type KeyType = SymbolStr;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self,
|
||||
_: &StableHashingContext<'a>)
|
||||
-> SymbolStr {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for ast::Name {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
|
|
|
@ -8,6 +8,7 @@ use rustc_index::vec::Idx;
|
|||
use rustc_macros::symbols;
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use rustc_serialize::{UseSpecializedDecodable, UseSpecializedEncodable};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher};
|
||||
|
||||
use std::cmp::{PartialEq, PartialOrd, Ord};
|
||||
use std::fmt;
|
||||
|
@ -1136,3 +1137,20 @@ impl fmt::Display for SymbolStr {
|
|||
fmt::Display::fmt(self.string, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX> HashStable<CTX> for SymbolStr {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
let str = self as &str;
|
||||
str.hash_stable(hcx, hasher)
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX> ToStableHashKey<CTX> for SymbolStr {
|
||||
type KeyType = SymbolStr;
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue