about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-07-06 11:28:32 +0000
committerbors <bors@rust-lang.org>2017-07-06 11:28:32 +0000
commitccf401f8f7847413ac43f38e3c86016becf67b07 (patch)
tree9f5e1653722b8bf4a16d05974ef32432e798b0e7 /src
parentafb853a3d742ada964ea06cccd422b08ea250cd3 (diff)
parent06e1fc06d75e0bc67dcf90b1a12368775ede7ce0 (diff)
downloadrust-ccf401f8f7847413ac43f38e3c86016becf67b07.tar.gz
rust-ccf401f8f7847413ac43f38e3c86016becf67b07.zip
Auto merge of #43078 - kennytm:fix-42755-vis-can-be-empty, r=petrochenkov
Disallow `$($v:vis)*`. Fix #42755.

#42755
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs1
-rw-r--r--src/test/compile-fail/issue-42755.rs17
2 files changed, 18 insertions, 0 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index b732f47ce6a..a98a9dd2040 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -299,6 +299,7 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[quoted::TokenTree]) -> bool {
             TokenTree::Sequence(span, ref seq) => {
                 if seq.separator.is_none() && seq.tts.iter().all(|seq_tt| {
                     match *seq_tt {
+                        TokenTree::MetaVarDecl(_, _, id) => id.name == "vis",
                         TokenTree::Sequence(_, ref sub_seq) =>
                             sub_seq.op == quoted::KleeneOp::ZeroOrMore,
                         _ => false,
diff --git a/src/test/compile-fail/issue-42755.rs b/src/test/compile-fail/issue-42755.rs
new file mode 100644
index 00000000000..7547c4a17be
--- /dev/null
+++ b/src/test/compile-fail/issue-42755.rs
@@ -0,0 +1,17 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(macro_vis_matcher)]
+
+macro_rules! foo {
+    ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree
+}
+
+foo!(a);