Skip to content

Commit

Permalink
Merge pull request #131 from dtolnay/star
Browse files Browse the repository at this point in the history
Fix missing star after repetition
  • Loading branch information
dtolnay authored Aug 18, 2019
2 parents 40b9852 + bce8f54 commit 53f65a5
Show file tree
Hide file tree
Showing 2 changed files with 18 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 @@ -715,6 +715,10 @@ macro_rules! quote_token_with_context {
}};
($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) $sep:tt * $a3:tt) => {};
($tokens:ident $span:ident $b3:tt # ( $($inner:tt)* ) ($sep:tt) * $a2:tt $a3:tt) => {};
($tokens:ident $span:ident # ( $($inner:tt)* ) * (*) $a1:tt $a2:tt $a3:tt) => {
// https://github.com/dtolnay/quote/issues/130
$crate::quote_token!($tokens $span *);
};
($tokens:ident $span:ident # ( $($inner:tt)* ) $sep:tt (*) $a1:tt $a2:tt $a3:tt) => {};

($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) $var:ident $a2:tt $a3:tt) => {
Expand Down
14 changes: 14 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,17 @@ fn test_inner_attr() {
let expected = "# ! [ no_std ]";
assert_eq!(expected, tokens.to_string());
}

// https://github.com/dtolnay/quote/issues/130
#[test]
fn test_star_after_repetition() {
let c = vec!['0', '1'];
let tokens = quote! {
#(
f(#c);
)*
*out = None;
};
let expected = "f ( '0' ) ; f ( '1' ) ; * out = None ;";
assert_eq!(expected, tokens.to_string());
}

0 comments on commit 53f65a5

Please sign in to comment.