summaryrefslogtreecommitdiff
path: root/src/macro_rules/parse.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-10-29 12:05:35 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-10-29 12:05:35 +0800
commit69311c5199292cd4b00b5c82fe8096d93b7e6465 (patch)
treedc59f6a929d416ee79d01a445d9fce35f480c299 /src/macro_rules/parse.cpp
parent0879111f1c8d287a394ca2c2c56c941ded0842ab (diff)
downloadmrust-69311c5199292cd4b00b5c82fe8096d93b7e6465.tar.gz
macro_rules - Patch around a quirk in error-chain
Diffstat (limited to 'src/macro_rules/parse.cpp')
-rw-r--r--src/macro_rules/parse.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/macro_rules/parse.cpp b/src/macro_rules/parse.cpp
index 5d478e64..38506a21 100644
--- a/src/macro_rules/parse.cpp
+++ b/src/macro_rules/parse.cpp
@@ -202,13 +202,18 @@ public:
}
}
+ //else if( tok.type() == TOK_IDENT || tok_is_rword(tok.type()) )
else if( tok.type() == TOK_IDENT || tok.type() == TOK_RWORD_TYPE || tok.type() == TOK_RWORD_PUB )
{
// Look up the named parameter in the list of param names for this arm
auto name = tok.type() == TOK_IDENT ? tok.str() : FMT(tok);
unsigned int idx = ::std::find(var_names.begin(), var_names.end(), name) - var_names.begin();
- if( idx == var_names.size() )
- ERROR(lex.point_span(), E0000, "Macro variable $" << name << " not found");
+ if( idx == var_names.size() ) {
+ // TODO: `error-chain`'s quick_error macro has an arm which refers to an undefined metavar.
+ // - Maybe emit a warning and use a marker index.
+ WARNING(lex.point_span(), W0000, "Macro variable $" << name << " not found");
+ idx = (1<<30)-1;
+ }
if( var_set_ptr ) {
var_set_ptr->insert( ::std::make_pair(idx,true) );
}