Description
Tracking issue for declarative macros 2.0 (aka macro
aka decl_macro aka macros-by-example).
RFC: https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md
RFC PR: rust-lang/rfcs#1584
cc @rust-lang/compiler
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Tasks
- Complete the draft hygiene prototype and RFC.
- Hygiene for items, explicit imports, lexical scopes, and module scopes.
- Hygiene for globs and trait methods (w.r.t. extension trait candidates in scope for a method call).
- Hygiene for type directed name resolutions (i.e. methods, associated types, and fields).
- Support
macro
in blocks as well as modules. - Implement inter-crate hygiene, except for nested
macro
s. - Implement "hygiene bending" for when users want a name from macro def to "escape".
- Implement inter-crate hygiene for nested
macro
s (pending macro def encoding). - Make
private_in_public
hygienic? - Make
unsafe
and lints hygienic (if appropriate)?
- Add variant
ast::ItemKind::MacroDef
formacro_rules!
items andmacro
items (PR syntax: addast::ItemKind::MacroDef
, simplify hygiene info #40220). - Encode
macro
s in the crate metadata usingTokenStream
, notString
. - Fix Inferred types should be checked for privacy violations #30476 (
private_in_public
details). - Fix span issues If an error is not affected by a macro, don't print macro notes #30506 and Spans for Paths can be incorrect #39450 (PR macros: improve
Span
's expansion information #40597). - Land
macro
behind a feature gate (PR Initial implementation of declarative macros 2.0 #40847). - Future-proof matchers (e.g.
$e:expr
) by employing a simpler, more general grammar. - Allow fragments (e.g.
$e
where$e:expr
) to be parsed in more contexts (c.f. Macro matching is incorrect for macros invoked in macro expansions #26361). - Decide whether we want macro invocations in identifier positions and/or eager expansion.
-
Remove $:meta matcher (Remove $:meta matcher in decl macros #49629)
Potentially blocking issues: