diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ich/impls_syntax.rs | 67 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/token.rs | 19 |
3 files changed, 12 insertions, 79 deletions
diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 2d7db94bf8c..144980c53eb 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -3,12 +3,8 @@ use crate::ich::StableHashingContext; -use std::hash as std_hash; -use std::mem; - use syntax::ast; use syntax::feature_gate; -use syntax::token; use syntax_pos::SourceFile; use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; @@ -65,68 +61,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ast::Attribute { } } -impl<'ctx> syntax::HashStableContext for StableHashingContext<'ctx> { - fn hash_stable_tokenkind(&mut self, tokenkind: &token::TokenKind, hasher: &mut StableHasher) { - mem::discriminant(tokenkind).hash_stable(self, hasher); - match *tokenkind { - token::Eq | - token::Lt | - token::Le | - token::EqEq | - token::Ne | - token::Ge | - token::Gt | - token::AndAnd | - token::OrOr | - token::Not | - token::Tilde | - token::At | - token::Dot | - token::DotDot | - token::DotDotDot | - token::DotDotEq | - token::Comma | - token::Semi | - token::Colon | - token::ModSep | - token::RArrow | - token::LArrow | - token::FatArrow | - token::Pound | - token::Dollar | - token::Question | - token::SingleQuote | - token::Whitespace | - token::Comment | - token::Eof => {} - - token::BinOp(bin_op_token) | - token::BinOpEq(bin_op_token) => { - std_hash::Hash::hash(&bin_op_token, hasher); - } - - token::OpenDelim(delim_token) | - token::CloseDelim(delim_token) => { - std_hash::Hash::hash(&delim_token, hasher); - } - token::Literal(lit) => lit.hash_stable(self, hasher), - - token::Ident(name, is_raw) => { - name.hash_stable(self, hasher); - is_raw.hash_stable(self, hasher); - } - token::Lifetime(name) => name.hash_stable(self, hasher), - - token::Interpolated(_) => { - bug!("interpolated tokens should not be present in the HIR") - } - - token::DocComment(val) | - token::Shebang(val) | - token::Unknown(val) => val.hash_stable(self, hasher), - } - } -} +impl<'ctx> syntax::HashStableContext for StableHashingContext<'ctx> {} impl<'a> HashStable<StableHashingContext<'a>> for SourceFile { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 579d2657939..22b49862f49 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -20,7 +20,6 @@ #![recursion_limit="256"] pub use errors; -use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::sync::Lock; use rustc_index::bit_set::GrowableBitSet; pub use rustc_data_structures::thin_vec::ThinVec; @@ -115,6 +114,4 @@ pub mod early_buffered_lints; /// Requirements for a `StableHashingContext` to be used in this crate. /// This is a hack to allow using the `HashStable_Generic` derive macro /// instead of implementing everything in librustc. -pub trait HashStableContext: syntax_pos::HashStableContext { - fn hash_stable_tokenkind(&mut self, tokenkind: &token::TokenKind, hasher: &mut StableHasher); -} +pub trait HashStableContext: syntax_pos::HashStableContext {} diff --git a/src/libsyntax/token.rs b/src/libsyntax/token.rs index 045e9f8689f..6f45211ac5f 100644 --- a/src/libsyntax/token.rs +++ b/src/libsyntax/token.rs @@ -19,6 +19,7 @@ use rustc_data_structures::sync::Lrc; use rustc_macros::HashStable_Generic; #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(HashStable_Generic)] pub enum BinOpToken { Plus, Minus, @@ -192,7 +193,7 @@ fn ident_can_begin_type(name: ast::Name, span: Span, is_raw: bool) -> bool { ].contains(&name) } -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum TokenKind { /* Expression-operator symbols. */ Eq, @@ -264,14 +265,6 @@ pub enum TokenKind { #[cfg(target_arch = "x86_64")] rustc_data_structures::static_assert_size!(TokenKind, 16); -impl<CTX> HashStable<CTX> for TokenKind - where CTX: crate::HashStableContext -{ - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - hcx.hash_stable_tokenkind(self, hasher) - } -} - #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub struct Token { pub kind: TokenKind, @@ -735,3 +728,11 @@ impl fmt::Debug for Nonterminal { } } } + +impl<CTX> HashStable<CTX> for Nonterminal + where CTX: crate::HashStableContext +{ + fn hash_stable(&self, _hcx: &mut CTX, _hasher: &mut StableHasher) { + panic!("interpolated tokens should not be present in the HIR") + } +} |
