Skip to content

Commit

Permalink
Backport test suite to work with rustc 1.31
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 10, 2020
1 parent 54f4996 commit aca6368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub fn expand_attr(
let mut leading_colons = 0; // $(::)?
let mut leading_path = 0; // $($ident)::+

let mut token;
let group = loop {
match tokens.next() {
token = tokens.next();
match token {
// colon after `$(:)?`
Some(TokenTree::Punct(ref punct))
if punct.as_char() == ':' && leading_colons < 2 && leading_path == 0 =>
Expand Down Expand Up @@ -43,7 +45,7 @@ pub fn expand_attr(
return Ok(attr);
}
// parens after `$(::)? $($ident)::+`
Some(TokenTree::Group(group))
Some(TokenTree::Group(ref group))
if group.delimiter() == Delimiter::Parenthesis && leading_path % 3 == 1 =>
{
break group;
Expand Down
6 changes: 4 additions & 2 deletions tests/macros/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extern crate proc_macro;

use proc_macro::{TokenStream, TokenTree};

#[proc_macro_attribute]
Expand All @@ -8,11 +10,11 @@ pub fn paste_test(args: TokenStream, input: TokenStream) -> TokenStream {
_ => panic!("{}", args),
}
match iter.next() {
Some(TokenTree::Punct(punct)) if punct.as_char() == '=' => {}
Some(TokenTree::Punct(ref punct)) if punct.as_char() == '=' => {}
_ => panic!("{}", args),
}
match iter.next() {
Some(TokenTree::Literal(literal)) if literal.to_string().starts_with('"') => {}
Some(TokenTree::Literal(ref literal)) if literal.to_string().starts_with('"') => {}
_ => panic!("{}", args),
}
match iter.next() {
Expand Down

0 comments on commit aca6368

Please sign in to comment.