]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/tokenstream.rs
Simplify Cache wrapper to single type, impl Deref on it, fix all compilation errors...
[rust.git] / src / libsyntax / tokenstream.rs
index eb99e549a7f6caf6499f6d6555b1993325665def..6a0523dd655b861d0d03b41f3c5ecbdda323d54d 100644 (file)
@@ -35,7 +35,7 @@
 ///
 /// 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 @@ fn _dummy()
     TokenStream: Send + Sync,
 {}
 
-impl<CTX> HashStable<CTX> for TokenTree
-    where CTX: crate::StableHashingContextLike
-{
-    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 {
@@ -138,7 +118,7 @@ pub fn close_tt(span: DelimSpan, delim: DelimToken) -> TokenTree {
 }
 
 impl<CTX> HashStable<CTX> for TokenStream
-    where CTX: crate::StableHashingContextLike
+    where CTX: crate::HashStableContext
 {
     fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
         for sub_tt in self.trees() {