@@ -143,6 +143,7 @@ impl ItemTree {
143143 mods,
144144 macro_calls,
145145 macro_rules,
146+ macro_defs,
146147 exprs,
147148 vis,
148149 generics,
@@ -164,6 +165,7 @@ impl ItemTree {
164165 mods. shrink_to_fit ( ) ;
165166 macro_calls. shrink_to_fit ( ) ;
166167 macro_rules. shrink_to_fit ( ) ;
168+ macro_defs. shrink_to_fit ( ) ;
167169 exprs. shrink_to_fit ( ) ;
168170
169171 vis. arena . shrink_to_fit ( ) ;
@@ -283,6 +285,7 @@ struct ItemTreeData {
283285 mods : Arena < Mod > ,
284286 macro_calls : Arena < MacroCall > ,
285287 macro_rules : Arena < MacroRules > ,
288+ macro_defs : Arena < MacroDef > ,
286289 exprs : Arena < Expr > ,
287290
288291 vis : ItemVisibilities ,
@@ -431,6 +434,7 @@ mod_items! {
431434 Mod in mods -> ast:: Module ,
432435 MacroCall in macro_calls -> ast:: MacroCall ,
433436 MacroRules in macro_rules -> ast:: MacroRules ,
437+ MacroDef in macro_defs -> ast:: MacroDef ,
434438}
435439
436440macro_rules! impl_index {
@@ -640,7 +644,7 @@ pub struct MacroCall {
640644
641645#[ derive( Debug , Clone , Eq , PartialEq ) ]
642646pub struct MacroRules {
643- /// For `macro_rules!` declarations, this is the name of the declared macro.
647+ /// The name of the declared macro.
644648 pub name : Name ,
645649 /// Has `#[macro_export]`.
646650 pub is_export : bool ,
@@ -651,6 +655,16 @@ pub struct MacroRules {
651655 pub ast_id : FileAstId < ast:: MacroRules > ,
652656}
653657
658+ /// "Macros 2.0" macro definition.
659+ #[ derive( Debug , Clone , Eq , PartialEq ) ]
660+ pub struct MacroDef {
661+ pub name : Name ,
662+ pub visibility : RawVisibilityId ,
663+ /// Has `#[rustc_builtin_macro]`.
664+ pub is_builtin : bool ,
665+ pub ast_id : FileAstId < ast:: MacroDef > ,
666+ }
667+
654668// NB: There's no `FileAstId` for `Expr`. The only case where this would be useful is for array
655669// lengths, but we don't do much with them yet.
656670#[ derive( Debug , Clone , Eq , PartialEq ) ]
@@ -680,7 +694,8 @@ impl ModItem {
680694 | ModItem :: Trait ( _)
681695 | ModItem :: Impl ( _)
682696 | ModItem :: Mod ( _)
683- | ModItem :: MacroRules ( _) => None ,
697+ | ModItem :: MacroRules ( _)
698+ | ModItem :: MacroDef ( _) => None ,
684699 ModItem :: MacroCall ( call) => Some ( AssocItem :: MacroCall ( * call) ) ,
685700 ModItem :: Const ( konst) => Some ( AssocItem :: Const ( * konst) ) ,
686701 ModItem :: TypeAlias ( alias) => Some ( AssocItem :: TypeAlias ( * alias) ) ,
@@ -708,6 +723,7 @@ impl ModItem {
708723 ModItem :: Mod ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
709724 ModItem :: MacroCall ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
710725 ModItem :: MacroRules ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
726+ ModItem :: MacroDef ( it) => tree[ it. index ] . ast_id ( ) . upcast ( ) ,
711727 }
712728 }
713729}
0 commit comments