@@ -5,6 +5,7 @@ use crate::rmeta::table::{FixedSizeEncoding, Table};
5
5
use crate :: rmeta:: * ;
6
6
7
7
use rustc_ast as ast;
8
+ use rustc_ast:: ptr:: P ;
8
9
use rustc_attr as attr;
9
10
use rustc_data_structures:: captures:: Captures ;
10
11
use rustc_data_structures:: fx:: FxHashMap ;
@@ -1076,6 +1077,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1076
1077
res,
1077
1078
vis : ty:: Visibility :: Public ,
1078
1079
span : ident. span ,
1080
+ macro_rules : false ,
1079
1081
} ) ;
1080
1082
}
1081
1083
}
@@ -1087,17 +1089,19 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1087
1089
for child_index in children. decode ( ( self , sess) ) {
1088
1090
if let Some ( ident) = self . opt_item_ident ( child_index, sess) {
1089
1091
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
- }
1095
1092
let def_id = self . local_def_id ( child_index) ;
1096
1093
let res = Res :: Def ( kind, def_id) ;
1097
1094
let vis = self . get_visibility ( child_index) ;
1098
1095
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
+ } ;
1099
1103
1100
- callback ( ModChild { ident, res, vis, span } ) ;
1104
+ callback ( ModChild { ident, res, vis, span, macro_rules } ) ;
1101
1105
1102
1106
// For non-re-export structs and variants add their constructors to children.
1103
1107
// Re-export lists automatically contain constructors when necessary.
@@ -1109,7 +1113,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1109
1113
let ctor_res =
1110
1114
Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id) ;
1111
1115
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
+ } ) ;
1113
1123
}
1114
1124
}
1115
1125
DefKind :: Variant => {
@@ -1134,7 +1144,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1134
1144
vis = ty:: Visibility :: Restricted ( crate_def_id) ;
1135
1145
}
1136
1146
}
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
+ } ) ;
1138
1154
}
1139
1155
_ => { }
1140
1156
}
@@ -1402,9 +1418,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1402
1418
tcx. arena . alloc_from_iter ( self . root . exported_symbols . decode ( ( self , tcx) ) )
1403
1419
}
1404
1420
1405
- fn get_macro ( self , id : DefIndex , sess : & Session ) -> MacroDef {
1421
+ fn get_macro ( self , id : DefIndex , sess : & Session ) -> ast :: MacroDef {
1406
1422
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
+ }
1408
1426
_ => bug ! ( ) ,
1409
1427
}
1410
1428
}
0 commit comments