-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
A-macromacro expansionmacro expansionB-unstableunstable featureunstable featureC-featureCategory: feature requestCategory: feature request
Description
- Tracking Issue for RFC 3697 "Declarative
macro_rules!attribute macros" (macro_attr) rust#143547 - Tracking Issue for RFC 3698 "Declarative
macro_rules!derive macros" (macro_derive) rust#143549
The Rust compiler has unstable support for using macro_rules! macros in attribute position or as derives, by prefixing individual rules with attr() or derive():
#![feature(macro_attr)]
#![feature(macro_derive)]
macro_rules! my_macro {
attr() ( $($tt:tt)* ) => { /* TODO */ };
derive() ( $($tt:tt)* ) => { /* TODO */ };
( $($tt:tt)* ) => { /* TODO */ };
}
// Use as bang macro:
my_macro!(...);
// Use as attribute macro:
#[my_macro]
struct MyStructA;
// Use as derive macro:
#[derive(my_macro)]
struct MyStructB;rust-analyzer hasn't added support for this macro_rules! syntax, so trying to use it results in a cryptic “expected subtree” error on the macro's name, not on the offending rules.
Furthermore, because rust-analyzer doesn't know how to expand declarative attribute/derive macros, any items declared by those expansions are not visible to r-a, making autocomplete and other IDE features much less helpful.
Metadata
Metadata
Assignees
Labels
A-macromacro expansionmacro expansionB-unstableunstable featureunstable featureC-featureCategory: feature requestCategory: feature request