diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-14 17:08:07 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-17 15:51:06 +0100 |
commit | 1a2ef9cae90db5bdb18723b6adafe2750a95ed76 (patch) | |
tree | c634ec46956c01a631ba528854975b45b82739a7 /gcc/rust/parse/rust-parse-impl.h | |
parent | 1a14348afefc62313e38156fde768744378f9ebf (diff) | |
download | gcc-1a2ef9cae90db5bdb18723b6adafe2750a95ed76.zip gcc-1a2ef9cae90db5bdb18723b6adafe2750a95ed76.tar.gz gcc-1a2ef9cae90db5bdb18723b6adafe2750a95ed76.tar.bz2 |
macros: Add remaining context and improve parsing macro dispatch
This allows us to expand macor invocations in more places, as macro
calls are not limited to statements or expressions. It is quite common
to use macros to abstract writing repetitive boilerplate for type
implementations, for example.
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 0bbd8fb..82e7e24 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -5251,12 +5251,11 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item () switch (t->get_id ()) { case IDENTIFIER: + // FIXME: Arthur: Do we need to some lookahead here? + return parse_macro_invocation_semi (outer_attrs); case SUPER: case SELF: case CRATE: - case DOLLAR_SIGN: - // these seem to be SimplePath tokens, so this is a macro invocation semi - return parse_macro_invocation_semi (std::move (outer_attrs)); case PUB: { // visibility, so not a macro invocation semi - must be constant, // function, or method @@ -5813,6 +5812,8 @@ Parser<ManagedTokenSource>::parse_external_item () const_TokenPtr t = lexer.peek_token (); switch (t->get_id ()) { + case IDENTIFIER: + return parse_macro_invocation_semi (outer_attrs); case STATIC_TOK: { // parse extern static item lexer.skip_token (); |