From 1dd5133dce33fed1cffea9bc6fb6ee4f37dc7053 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 21:17:21 +0100 Subject: [PATCH] Move impl HashStable for Symbol in libsyntax_pos. --- src/librustc/ich/impls_syntax.rs | 21 +-------------------- src/libsyntax_pos/symbol.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 4a331cbf40d..005d03f4d0a 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -10,31 +10,12 @@ use syntax::ast; use syntax::feature_gate; use syntax::token; use syntax::tokenstream; -use syntax_pos::symbol::SymbolStr; use syntax_pos::SourceFile; 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> for ast::Name { - #[inline] - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - self.as_str().hash_stable(hcx, hasher); - } -} - -impl<'a> ToStableHashKey> for ast::Name { - type KeyType = SymbolStr; - - #[inline] - fn to_stable_hash_key(&self, - _: &StableHashingContext<'a>) - -> SymbolStr { - self.as_str() - } -} +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind { Bang, diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 63368831614..f6377633857 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -940,6 +940,22 @@ impl Decodable for Symbol { } } +impl HashStable for Symbol { + #[inline] + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + self.as_str().hash_stable(hcx, hasher); + } +} + +impl ToStableHashKey for Symbol { + type KeyType = SymbolStr; + + #[inline] + fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr { + self.as_str() + } +} + // The `&'static str`s in this type actually point into the arena. #[derive(Default)] pub struct Interner {