From e01a2ba2743bb72d86bf96df72af98ab06ad47eb Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Mon, 27 Jun 2016 03:15:06 +0000 Subject: [PATCH 1/2] Forbid type parameters and global paths in macro invocations --- src/libsyntax/ext/expand.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 5beb4937207..89e346be944 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -214,7 +214,7 @@ fn expand_mac_invoc(mac: ast::Mac, ident: Option, attrs: Vec 1 { + if path.segments.len() > 1 || path.global || !path.segments[0].parameters.is_empty() { fld.cx.span_err(path.span, "expected macro name without module separators"); return None; } From b4611b1ff29d93ba9a03932b316935cbfd076ed9 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Mon, 27 Jun 2016 03:17:55 +0000 Subject: [PATCH 2/2] Add regression test --- src/test/compile-fail/macro-with-seps-err-msg.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs index 95250e36b86..408bb15ba28 100644 --- a/src/test/compile-fail/macro-with-seps-err-msg.rs +++ b/src/test/compile-fail/macro-with-seps-err-msg.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected macro name without module separators - fn main() { - globnar::brotz!(); + globnar::brotz!(); //~ ERROR expected macro name without module separators + ::foo!(); //~ ERROR expected macro name without module separators + foo::!(); //~ ERROR expected macro name without module separators }