Erroneous expression parsing of macro invocations with paths #44065
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Consider the following
rustc
internal code which parses anast::Path
and returns an invocation of a macro at that path:The expected expansion of a procedural macro implemented in this manner is
PATH ! ( )
. Instead, this expands toPATH
erroneously. Said another way, if the code above corresponded to a macro namedm
, we would expectm!(some_path);
to expand tosome_path!()
when it instead expands tosome_path
.Note that if instead an
ast::Ident
is used in place of theast::Path
above, things work as expected. This corresponds to the code below:After some investigation, the issue appears to reside in
Parser::parse_expr
. I've created a repository where the issue can be reproduced: https://github.com/SergioBenitez/path-macro-repro. The repository also includes a work around for the problem (https://github.com/SergioBenitez/path-macro-repro/blob/master/src/lib.rs#L27).The text was updated successfully, but these errors were encountered: