1
Fork 0

Use proc-macro for TokenTree.

This commit is contained in:
Camille GILLOT 2019-11-23 14:41:56 +01:00
parent 7e411e7f55
commit 4d1674f620
2 changed files with 2 additions and 21 deletions

View file

@ -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,

View file

@ -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 {