Skip to content

Commit

Permalink
Recognize ident tokens instead of doing is_ident at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 11, 2019
1 parent ed61aae commit 8d155b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,10 @@ macro_rules! quote_token {
$crate::__rt::push_sub_eq(&mut $tokens, $span);
};

($tokens:ident $span:ident $ident:ident) => {
$crate::__rt::push_ident(&mut $tokens, $span, stringify!($ident));
};

($tokens:ident $span:ident $other:tt) => {
$crate::__rt::parse(&mut $tokens, $span, stringify!($other));
};
Expand Down
4 changes: 4 additions & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) {
}
}

pub fn push_ident(tokens: &mut TokenStream, span: Span, s: &str) {
tokens.append(Ident::new(s, span));
}

macro_rules! push_punct {
($name:ident $char1:tt) => {
pub fn $name(tokens: &mut TokenStream, span: Span) {
Expand Down

0 comments on commit 8d155b0

Please sign in to comment.