about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-05 06:44:48 +0200
committerGitHub <noreply@github.com>2020-04-05 06:44:48 +0200
commitd0dda18bd16d3efbd8fd8e19a69f520fd7613b9c (patch)
tree7594e970fb7ebd68141e579e81baeb2f0745a5fa /src
parent590cb8b3b0897af135c327d83f0227a40e4cde8b (diff)
parent106b30e86989cb4f201ef7a1b7fac7150b662b92 (diff)
downloadrust-d0dda18bd16d3efbd8fd8e19a69f520fd7613b9c.tar.gz
rust-d0dda18bd16d3efbd8fd8e19a69f520fd7613b9c.zip
Rollup merge of #70768 - petrochenkov:macambig, r=Centril,mark-i-m
macro_rules: `NtLifetime` cannot start with an identifier

Fixes https://github.com/rust-lang/rust/issues/70446
Diffstat (limited to 'src')
-rw-r--r--src/librustc_expand/mbe/macro_parser.rs2
-rw-r--r--src/test/ui/macros/issue-70446.rs13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc_expand/mbe/macro_parser.rs b/src/librustc_expand/mbe/macro_parser.rs
index e868b7e36aa..5fb800972c7 100644
--- a/src/librustc_expand/mbe/macro_parser.rs
+++ b/src/librustc_expand/mbe/macro_parser.rs
@@ -768,7 +768,7 @@ fn may_begin_with(token: &Token, name: Name) -> bool {
     /// Checks whether the non-terminal may contain a single (non-keyword) identifier.
     fn may_be_ident(nt: &token::Nonterminal) -> bool {
         match *nt {
-            token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) => false,
+            token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) | token::NtLifetime(_) => false,
             _ => true,
         }
     }
diff --git a/src/test/ui/macros/issue-70446.rs b/src/test/ui/macros/issue-70446.rs
new file mode 100644
index 00000000000..407094d55ff
--- /dev/null
+++ b/src/test/ui/macros/issue-70446.rs
@@ -0,0 +1,13 @@
+// check-pass
+
+macro_rules! foo {
+    ($(: $p:path)? $(: $l:lifetime)? ) => { bar! {$(: $p)? $(: $l)? } };
+}
+
+macro_rules! bar {
+    ($(: $p:path)? $(: $l:lifetime)? ) => {};
+}
+
+foo! {: 'a }
+
+fn main() {}