Builtin metavars are not in the fragment, the compiler should not emit
an error message.
gcc/rust/ChangeLog:
* expand/rust-macro-substitute-ctx.cc (is_builtin_metavariable): Add
function to check builtin metavars knowledge.
(SubstituteCtx::check_repetition_amount): Do not process missing
fragment.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
return true;
}
+static bool
+is_builtin_metavariable (AST::Token &token)
+{
+ return token.get_id () == CRATE;
+}
+
bool
SubstituteCtx::check_repetition_amount (size_t pattern_start,
size_t pattern_end,
|| frag_token->get_id () == IDENTIFIER)
{
auto it = fragments.find (frag_token->get_str ());
+
+ if (is_builtin_metavariable (*frag_token))
+ continue;
+
if (it == fragments.end ())
{
// If the repetition is not anything we know (ie no declared
frag_token->get_str ().c_str ());
is_valid = false;
+ continue;
}
auto &fragment = *it->second;