about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2019-11-23 14:41:56 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2019-11-23 18:22:24 +0100
commit4d1674f62007053ddeba44e27459e18128cc97cf (patch)
treec1fca559dc568a26627bf838c24c9298abcb5f0b
parent7e411e7f55a6050fb690f2c4e46b002a46502031 (diff)
downloadrust-4d1674f62007053ddeba44e27459e18128cc97cf.tar.gz
rust-4d1674f62007053ddeba44e27459e18128cc97cf.zip
Use proc-macro for TokenTree.
-rw-r--r--src/libsyntax/token.rs1
-rw-r--r--src/libsyntax/tokenstream.rs22
2 files changed, 2 insertions, 21 deletions
diff --git a/src/libsyntax/token.rs b/src/libsyntax/token.rs
index 08afca921fc..045e9f8689f 100644
--- a/src/libsyntax/token.rs
+++ b/src/libsyntax/token.rs
@@ -34,6 +34,7 @@ pub enum BinOpToken {
 
 /// A delimiter token.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(HashStable_Generic)]
 pub enum DelimToken {
     /// A round parenthesis (i.e., `(` or `)`).
     Paren,
diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs
index 5ec99fa2f08..6a0523dd655 100644
--- a/src/libsyntax/tokenstream.rs
+++ b/src/libsyntax/tokenstream.rs
@@ -35,7 +35,7 @@ use std::{iter, mem};
 ///
 /// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
 /// Nothing special happens to misnamed or misplaced `SubstNt`s.
-#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable)]
+#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
 pub enum TokenTree {
     /// A single token
     Token(Token),
@@ -53,26 +53,6 @@ where
     TokenStream: Send + Sync,
 {}
 
-impl<CTX> HashStable<CTX> for TokenTree
-    where CTX: crate::HashStableContext
-{
-    fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
-        mem::discriminant(self).hash_stable(hcx, hasher);
-        match *self {
-            TokenTree::Token(ref token) => {
-                token.hash_stable(hcx, hasher);
-            }
-            TokenTree::Delimited(span, delim, ref tts) => {
-                span.hash_stable(hcx, hasher);
-                std::hash::Hash::hash(&delim, hasher);
-                for sub_tt in tts.trees() {
-                    sub_tt.hash_stable(hcx, hasher);
-                }
-            }
-        }
-    }
-}
-
 impl TokenTree {
     /// Checks if this TokenTree is equal to the other, regardless of span information.
     pub fn eq_unspanned(&self, other: &TokenTree) -> bool {