From 4f3a968f91bbc2991056e1fb7e6e38829bbce57d Mon Sep 17 00:00:00 2001 From: John Clements Date: Mon, 4 Mar 2013 13:58:31 -0800 Subject: better error message for macros with MOD_SEPs --- src/libsyntax/ext/expand.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 858ce4b17a3..ce8bf797ddb 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -38,10 +38,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, got: '%?'",pth)); + } /* using idents and token::special_idents would make the the macro names be hygienic */ let extname = cx.parse_sess().interner.get(pth.idents[0]); @@ -320,8 +324,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, got: '%?'",pth)); + } let extname = cx.parse_sess().interner.get(pth.idents[0]); let (fully_expanded, sp) = match (*extsbox).find(&extname) { None => -- cgit 1.4.1-3-g733a5 From a191babbe56170380c6d9b6a26ebf472b7c5dd37 Mon Sep 17 00:00:00 2001 From: John Clements Date: Mon, 4 Mar 2013 16:50:52 -0800 Subject: simplified msg (TMI on old one) --- src/libsyntax/ext/expand.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index ce8bf797ddb..cb04b2c55ae 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -44,7 +44,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, cx.span_fatal( pth.span, fmt!("expected macro name without module \ - separators, got: '%?'",pth)); + separators")); } /* using idents and token::special_idents would make the the macro names be hygienic */ @@ -328,7 +328,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, cx.span_fatal( pth.span, fmt!("expected macro name without module \ - separators, got: '%?'",pth)); + separators")); } let extname = cx.parse_sess().interner.get(pth.idents[0]); let (fully_expanded, sp) = match (*extsbox).find(&extname) { -- cgit 1.4.1-3-g733a5