diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2019-11-23 14:47:31 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2019-11-23 18:52:23 +0100 |
| commit | 782cc9f65c0c19ef79bd009074e09bf0394674f4 (patch) | |
| tree | c367a73f0bcc04651ec1fb77f6ba9655d4a94353 /src/libsyntax/token.rs | |
| parent | 4d1674f62007053ddeba44e27459e18128cc97cf (diff) | |
| download | rust-782cc9f65c0c19ef79bd009074e09bf0394674f4.tar.gz rust-782cc9f65c0c19ef79bd009074e09bf0394674f4.zip | |
Derive HashStable for TokenKind.
Diffstat (limited to 'src/libsyntax/token.rs')
| -rw-r--r-- | src/libsyntax/token.rs | 19 |
1 files changed, 10 insertions, 9 deletions
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") + } +} |
