aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2019-08-17 19:57:15 -0700
committerGitHub <noreply@github.com>2019-08-17 19:57:15 -0700
commit53f65a5e5eadb8ac2cbae9fd09a31724352447e4 (patch)
tree979f549a32bf735b58482140d0c14bb799caf103
parent40b985223063562beaad0c86a07052a004ed8fb6 (diff)
parentbce8f54e720a75f41814b03c792de37765dfecd7 (diff)
downloadplatform_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.rs4
-rw-r--r--tests/test.rs14
2 files changed, 18 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e9749ec..7b8d646 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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());
+}