Use proc-macro for TokenTree.
This commit is contained in:
parent
7e411e7f55
commit
4d1674f620
2 changed files with 2 additions and 21 deletions
|
@ -34,6 +34,7 @@ pub enum BinOpToken {
|
||||||
|
|
||||||
/// A delimiter token.
|
/// A delimiter token.
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
|
#[derive(HashStable_Generic)]
|
||||||
pub enum DelimToken {
|
pub enum DelimToken {
|
||||||
/// A round parenthesis (i.e., `(` or `)`).
|
/// A round parenthesis (i.e., `(` or `)`).
|
||||||
Paren,
|
Paren,
|
||||||
|
|
|
@ -35,7 +35,7 @@ use std::{iter, mem};
|
||||||
///
|
///
|
||||||
/// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
|
/// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
|
||||||
/// Nothing special happens to misnamed or misplaced `SubstNt`s.
|
/// 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 {
|
pub enum TokenTree {
|
||||||
/// A single token
|
/// A single token
|
||||||
Token(Token),
|
Token(Token),
|
||||||
|
@ -53,26 +53,6 @@ where
|
||||||
TokenStream: Send + Sync,
|
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 {
|
impl TokenTree {
|
||||||
/// Checks if this TokenTree is equal to the other, regardless of span information.
|
/// Checks if this TokenTree is equal to the other, regardless of span information.
|
||||||
pub fn eq_unspanned(&self, other: &TokenTree) -> bool {
|
pub fn eq_unspanned(&self, other: &TokenTree) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue