diff options
author | David Tolnay <dtolnay@gmail.com> | 2019-08-17 19:57:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-17 19:57:15 -0700 |
commit | 53f65a5e5eadb8ac2cbae9fd09a31724352447e4 (patch) | |
tree | 979f549a32bf735b58482140d0c14bb799caf103 | |
parent | 40b985223063562beaad0c86a07052a004ed8fb6 (diff) | |
parent | bce8f54e720a75f41814b03c792de37765dfecd7 (diff) | |
download | platform_external_rust_crates_quote-53f65a5e5eadb8ac2cbae9fd09a31724352447e4.tar.gz platform_external_rust_crates_quote-53f65a5e5eadb8ac2cbae9fd09a31724352447e4.tar.bz2 platform_external_rust_crates_quote-53f65a5e5eadb8ac2cbae9fd09a31724352447e4.zip |
Merge pull request #131 from dtolnay/star
Fix missing star after repetition
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | tests/test.rs | 14 |
2 files changed, 18 insertions, 0 deletions
@@ -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) => { diff --git a/tests/test.rs b/tests/test.rs index 6421172..957d470 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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()); +} |