Skip to content

Commit 4d1674f

Browse files
committed
Use proc-macro for TokenTree.
1 parent 7e411e7 commit 4d1674f

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

src/libsyntax/token.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub enum BinOpToken {
3434

3535
/// A delimiter token.
3636
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
37+
#[derive(HashStable_Generic)]
3738
pub enum DelimToken {
3839
/// A round parenthesis (i.e., `(` or `)`).
3940
Paren,

src/libsyntax/tokenstream.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use std::{iter, mem};
3535
///
3636
/// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
3737
/// Nothing special happens to misnamed or misplaced `SubstNt`s.
38-
#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable)]
38+
#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
3939
pub enum TokenTree {
4040
/// A single token
4141
Token(Token),
@@ -53,26 +53,6 @@ where
5353
TokenStream: Send + Sync,
5454
{}
5555

56-
impl<CTX> HashStable<CTX> for TokenTree
57-
where CTX: crate::HashStableContext
58-
{
59-
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
60-
mem::discriminant(self).hash_stable(hcx, hasher);
61-
match *self {
62-
TokenTree::Token(ref token) => {
63-
token.hash_stable(hcx, hasher);
64-
}
65-
TokenTree::Delimited(span, delim, ref tts) => {
66-
span.hash_stable(hcx, hasher);
67-
std::hash::Hash::hash(&delim, hasher);
68-
for sub_tt in tts.trees() {
69-
sub_tt.hash_stable(hcx, hasher);
70-
}
71-
}
72-
}
73-
}
74-
}
75-
7656
impl TokenTree {
7757
/// Checks if this TokenTree is equal to the other, regardless of span information.
7858
pub fn eq_unspanned(&self, other: &TokenTree) -> bool {

0 commit comments

Comments
 (0)