@@ -5,6 +5,7 @@ use crate::rmeta::table::{FixedSizeEncoding, Table};
55use crate :: rmeta:: * ;
66
77use rustc_ast as ast;
8+ use rustc_ast:: ptr:: P ;
89use rustc_attr as attr;
910use rustc_data_structures:: captures:: Captures ;
1011use rustc_data_structures:: fx:: FxHashMap ;
@@ -1076,6 +1077,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10761077 res,
10771078 vis : ty:: Visibility :: Public ,
10781079 span : ident. span ,
1080+ macro_rules : false ,
10791081 } ) ;
10801082 }
10811083 }
@@ -1087,17 +1089,19 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10871089 for child_index in children. decode ( ( self , sess) ) {
10881090 if let Some ( ident) = self . opt_item_ident ( child_index, sess) {
10891091 let kind = self . def_kind ( child_index) ;
1090- if matches ! ( kind, DefKind :: Macro ( ..) ) {
1091- // FIXME: Macros are currently encoded twice, once as items and once as
1092- // reexports. We ignore the items here and only use the reexports.
1093- continue ;
1094- }
10951092 let def_id = self . local_def_id ( child_index) ;
10961093 let res = Res :: Def ( kind, def_id) ;
10971094 let vis = self . get_visibility ( child_index) ;
10981095 let span = self . get_span ( child_index, sess) ;
1096+ let macro_rules = match kind {
1097+ DefKind :: Macro ( ..) => match self . kind ( child_index) {
1098+ EntryKind :: MacroDef ( _, macro_rules) => macro_rules,
1099+ _ => unreachable ! ( ) ,
1100+ } ,
1101+ _ => false ,
1102+ } ;
10991103
1100- callback ( ModChild { ident, res, vis, span } ) ;
1104+ callback ( ModChild { ident, res, vis, span, macro_rules } ) ;
11011105
11021106 // For non-re-export structs and variants add their constructors to children.
11031107 // Re-export lists automatically contain constructors when necessary.
@@ -1109,7 +1113,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11091113 let ctor_res =
11101114 Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id) ;
11111115 let vis = self . get_visibility ( ctor_def_id. index ) ;
1112- callback ( ModChild { ident, res : ctor_res, vis, span } ) ;
1116+ callback ( ModChild {
1117+ ident,
1118+ res : ctor_res,
1119+ vis,
1120+ span,
1121+ macro_rules : false ,
1122+ } ) ;
11131123 }
11141124 }
11151125 DefKind :: Variant => {
@@ -1134,7 +1144,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11341144 vis = ty:: Visibility :: Restricted ( crate_def_id) ;
11351145 }
11361146 }
1137- callback ( ModChild { ident, res : ctor_res, vis, span } ) ;
1147+ callback ( ModChild {
1148+ ident,
1149+ res : ctor_res,
1150+ vis,
1151+ span,
1152+ macro_rules : false ,
1153+ } ) ;
11381154 }
11391155 _ => { }
11401156 }
@@ -1402,9 +1418,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14021418 tcx. arena . alloc_from_iter ( self . root . exported_symbols . decode ( ( self , tcx) ) )
14031419 }
14041420
1405- fn get_macro ( self , id : DefIndex , sess : & Session ) -> MacroDef {
1421+ fn get_macro ( self , id : DefIndex , sess : & Session ) -> ast :: MacroDef {
14061422 match self . kind ( id) {
1407- EntryKind :: MacroDef ( macro_def) => macro_def. decode ( ( self , sess) ) ,
1423+ EntryKind :: MacroDef ( mac_args, macro_rules) => {
1424+ ast:: MacroDef { body : P ( mac_args. decode ( ( self , sess) ) ) , macro_rules }
1425+ }
14081426 _ => bug ! ( ) ,
14091427 }
14101428 }
0 commit comments