use crate::ast;
use crate::ptr::P;
-use crate::tokenstream::TokenTree;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
Integer,
Float,
Str,
- StrRaw(u16), // raw string delimited by `n` hash symbols
+ StrRaw(u8), // raw string delimited by `n` hash symbols
ByteStr,
- ByteStrRaw(u16), // raw byte string delimited by `n` hash symbols
+ ByteStrRaw(u8), // raw byte string delimited by `n` hash symbols
Err,
}
/// Returns `true` if the token is an interpolated path.
fn is_path(&self) -> bool {
- if let Interpolated(ref nt) = self.kind {
- if let NtPath(..) = **nt {
- return true;
- }
+ if let Interpolated(ref nt) = self.kind && let NtPath(..) = **nt {
+ return true;
}
false
}
/// That is, is this a pre-parsed expression dropped into the token stream
/// (which happens while parsing the result of macro expansion)?
pub fn is_whole_expr(&self) -> bool {
- if let Interpolated(ref nt) = self.kind {
- if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt {
- return true;
- }
+ if let Interpolated(ref nt) = self.kind
+ && let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt
+ {
+ return true;
}
false
// Is the token an interpolated block (`$b:block`)?
pub fn is_whole_block(&self) -> bool {
- if let Interpolated(ref nt) = self.kind {
- if let NtBlock(..) = **nt {
- return true;
- }
+ if let Interpolated(ref nt) = self.kind && let NtBlock(..) = **nt {
+ return true;
}
false
}
NtMeta(P<ast::AttrItem>),
NtPath(ast::Path),
NtVis(ast::Visibility),
- NtTT(TokenTree),
}
// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger.
NtMeta(attr_item) => attr_item.span(),
NtPath(path) => path.span,
NtVis(vis) => vis.span,
- NtTT(tt) => tt.span(),
}
}
}
ident_lhs == ident_rhs && is_raw_lhs == is_raw_rhs
}
(NtLifetime(ident_lhs), NtLifetime(ident_rhs)) => ident_lhs == ident_rhs,
- (NtTT(tt_lhs), NtTT(tt_rhs)) => tt_lhs == tt_rhs,
// FIXME: Assume that all "complex" nonterminal are not equal, we can't compare them
// correctly based on data from AST. This will prevent them from matching each other
// in macros. The comparison will become possible only when each nonterminal has an
NtLiteral(..) => f.pad("NtLiteral(..)"),
NtMeta(..) => f.pad("NtMeta(..)"),
NtPath(..) => f.pad("NtPath(..)"),
- NtTT(..) => f.pad("NtTT(..)"),
NtVis(..) => f.pad("NtVis(..)"),
NtLifetime(..) => f.pad("NtLifetime(..)"),
}