Skip to content

Commit

Permalink
Use proc-macro for TokenTree.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Nov 23, 2019
1 parent 7e411e7 commit 4d1674f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/libsyntax/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 1 addition & 21 deletions src/libsyntax/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 {
Expand Down

0 comments on commit 4d1674f

Please sign in to comment.