-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
macros should be parsed more lazily #6994
Copy link
Copy link
Closed
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTA-syntaxextArea: Syntax extensionsArea: Syntax extensionsP-lowLow priorityLow priority
Metadata
Metadata
Assignees
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTA-syntaxextArea: Syntax extensionsArea: Syntax extensionsP-lowLow priorityLow priority
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is a FIXME issue; currently, macro invocations are parsed too eagerly. In particular, the current system decides before expansion time whether a rhs pattern-use (e.g. $y) is bound or unbound. This is incompatible with macro-producing macros that use a given identifier in a pattern position. It's also incompatible with macros inside macros, where inner binding patterns are believed to be pattern uses. The solution is to delay this decision until the macro is encountered at expansion-time, by which time all outer macros have been expanded.
Here's an example of a macro that doesn't work in the current system:
Trying to expand this yields this error:
... indicating that the $y is believed to be a use, rather than a binder.