From 610d1e312f4d8ec13755015c69d5ae410039b06a Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Fri, 24 Jul 2015 01:09:52 +0000 Subject: [PATCH 1/3] Add test for issue #23389 --- src/test/compile-fail/invalid-macro-matcher.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/test/compile-fail/invalid-macro-matcher.rs diff --git a/src/test/compile-fail/invalid-macro-matcher.rs b/src/test/compile-fail/invalid-macro-matcher.rs new file mode 100644 index 0000000000000..568bac1d89d71 --- /dev/null +++ b/src/test/compile-fail/invalid-macro-matcher.rs @@ -0,0 +1,6 @@ +macro_rules! invalid { //~ ERROR Invalid macro matcher + _ => (); +} + +fn main() { +} From 4f58db485d82a8d4d4f03f9584ba6de347f704a5 Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Fri, 24 Jul 2015 01:10:25 +0000 Subject: [PATCH 2/3] Make ICE an error and use a sensible error message --- src/libsyntax/ext/tt/macro_rules.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 634572d46940e..e29e0ab54d17f 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -302,8 +302,8 @@ fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &NamedMatch, sp: Span) { tt @ &TtSequence(..) => { check_matcher(cx, Some(tt).into_iter(), &Eof); }, - _ => cx.span_bug(sp, "wrong-structured lhs for follow check (didn't find \ - a TtDelimited or TtSequence)") + _ => cx.span_err(sp, "Invalid macro matcher; matchers must be contained \ + in balanced delimiters or a repetition indicator") }, _ => cx.span_bug(sp, "wrong-structured lhs for follow check (didn't find a \ MatchedNonterminal)") From 93dd75a5096c615bfdbc4502deafce2ee606b00e Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Fri, 24 Jul 2015 01:39:47 +0000 Subject: [PATCH 3/3] Fix license statement --- src/test/compile-fail/invalid-macro-matcher.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/compile-fail/invalid-macro-matcher.rs b/src/test/compile-fail/invalid-macro-matcher.rs index 568bac1d89d71..302bf34ff9916 100644 --- a/src/test/compile-fail/invalid-macro-matcher.rs +++ b/src/test/compile-fail/invalid-macro-matcher.rs @@ -1,5 +1,15 @@ -macro_rules! invalid { //~ ERROR Invalid macro matcher - _ => (); +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! invalid { + _ => (); //~^ ERROR Invalid macro matcher } fn main() {