diff options
| author | bors <bors@rust-lang.org> | 2013-03-05 10:06:50 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-05 10:06:50 -0800 |
| commit | e94465c053b06a5e4e0394812a12f4f6e027a98e (patch) | |
| tree | 51048b6c635bd977b178c98d22d1950d1d59900a /src/libsyntax | |
| parent | afd6196d7b87401d20dc5149c6955e2c9758657f (diff) | |
| parent | fe08364b3be5463e28650a6ed8cdd203b775208a (diff) | |
| download | rust-e94465c053b06a5e4e0394812a12f4f6e027a98e.tar.gz rust-e94465c053b06a5e4e0394812a12f4f6e027a98e.zip | |
auto merge of #5231 : jbclements/rust/better-macro-error-message, r=graydon
Macro invocations with path separators (e.g. foo::bar!()) now produce a sensible error message, rather than an assertion failure. Also added compile-fail test case. Fixes #5218 ?
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 97c75e65e1d..03633a89a86 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -37,10 +37,14 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // entry-point for all syntax extensions. expr_mac(ref mac) => { match (*mac).node { - // Token-tree macros, these will be the only case when we're - // finished transitioning. + // Token-tree macros: mac_invoc_tt(pth, ref tts) => { - assert (vec::len(pth.idents) == 1u); + if (pth.idents.len() > 1u) { + cx.span_fatal( + pth.span, + fmt!("expected macro name without module \ + separators")); + } /* using idents and token::special_idents would make the the macro names be hygienic */ let extname = cx.parse_sess().interner.get(pth.idents[0]); @@ -319,8 +323,12 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, } _ => return orig(s, sp, fld) }; - - assert(vec::len(pth.idents) == 1u); + if (pth.idents.len() > 1u) { + cx.span_fatal( + pth.span, + fmt!("expected macro name without module \ + separators")); + } let extname = cx.parse_sess().interner.get(pth.idents[0]); let (fully_expanded, sp) = match (*extsbox).find(&extname) { None => |
