From 44d040f6d4325f713b9fefeadb1ee533a0fd5294 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 30 Dec 2018 15:08:38 +0800 Subject: Parse/Macro - Handle `crate` as a visibility specifier --- src/macro_rules/eval.cpp | 4 ++-- src/macro_rules/mod.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/macro_rules') diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp index 558f26b3..23ffab77 100644 --- a/src/macro_rules/eval.cpp +++ b/src/macro_rules/eval.cpp @@ -1824,7 +1824,7 @@ namespace bool consume_vis(TokenStreamRO& lex) { TRACE_FUNCTION; - if( lex.consume_if(TOK_INTERPOLATED_VIS) ) + if( lex.consume_if(TOK_INTERPOLATED_VIS) || lex.consume_if(TOK_RWORD_CRATE) ) { return true; } @@ -2065,7 +2065,7 @@ unsigned int Macro_InvokeRules_MatchPattern(const Span& sp, const MacroRules& ru DEBUG(i << " ExpectTok(" << *e << ") == " << tok); if( tok != *e ) { - ERROR(sp, E0000, "Expected token in match arm"); + ERROR(sp, E0000, "Expected token " << *e << " in match arm, got " << tok); break; } } diff --git a/src/macro_rules/mod.cpp b/src/macro_rules/mod.cpp index fcea5b25..3297a139 100644 --- a/src/macro_rules/mod.cpp +++ b/src/macro_rules/mod.cpp @@ -160,6 +160,7 @@ bool is_token_vis(eTokenType tt) { switch(tt) { case TOK_RWORD_PUB: + case TOK_RWORD_CRATE: case TOK_INTERPOLATED_VIS: return true; default: -- cgit v1.2.3