@@ -170,7 +170,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
170170 self . lower_item_id_use_tree ( use_tree, i. id , & mut vec) ;
171171 vec
172172 }
173- ItemKind :: MacroDef ( ..) => SmallVec :: new ( ) ,
174173 ItemKind :: Fn ( ..) | ItemKind :: Impl ( box ImplKind { of_trait : None , .. } ) => {
175174 smallvec ! [ i. id]
176175 }
@@ -212,28 +211,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
212211 pub fn lower_item ( & mut self , i : & Item ) -> Option < hir:: Item < ' hir > > {
213212 let mut ident = i. ident ;
214213 let mut vis = self . lower_visibility ( & i. vis , None ) ;
215-
216- if let ItemKind :: MacroDef ( MacroDef { ref body, macro_rules } ) = i. kind {
217- if !macro_rules || self . sess . contains_name ( & i. attrs , sym:: macro_export) {
218- let hir_id = self . lower_node_id ( i. id ) ;
219- self . lower_attrs ( hir_id, & i. attrs ) ;
220- let body = P ( self . lower_mac_args ( body) ) ;
221- self . insert_macro_def ( hir:: MacroDef {
222- ident,
223- vis,
224- def_id : hir_id. expect_owner ( ) ,
225- span : i. span ,
226- ast : MacroDef { body, macro_rules } ,
227- } ) ;
228- } else {
229- for a in i. attrs . iter ( ) {
230- let a = self . lower_attr ( a) ;
231- self . non_exported_macro_attrs . push ( a) ;
232- }
233- }
234- return None ;
235- }
236-
237214 let hir_id = self . lower_node_id ( i. id ) ;
238215 let attrs = self . lower_attrs ( hir_id, & i. attrs ) ;
239216 let kind = self . lower_item_kind ( i. span , i. id , hir_id, & mut ident, attrs, & mut vis, & i. kind ) ;
@@ -465,7 +442,26 @@ impl<'hir> LoweringContext<'_, 'hir> {
465442 self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
466443 self . lower_param_bounds ( bounds, ImplTraitContext :: disallowed ( ) ) ,
467444 ) ,
468- ItemKind :: MacroDef ( ..) | ItemKind :: MacCall ( ..) => {
445+ ItemKind :: MacroDef ( MacroDef { ref body, macro_rules } ) => {
446+ let is_exported = !macro_rules
447+ || attrs. map_or ( false , |a| self . sess . contains_name ( a, sym:: macro_export) ) ;
448+
449+ let body = P ( self . lower_mac_args ( body) ) ;
450+
451+ hir:: ItemKind :: Macro {
452+ // `is_exported` is duplicated, to make matching more convenient.
453+ is_exported,
454+ macro_def : hir:: MacroDef {
455+ is_exported,
456+ ident : * ident,
457+ vis : * vis,
458+ def_id : hir_id. expect_owner ( ) ,
459+ span,
460+ ast : MacroDef { body, macro_rules } ,
461+ } ,
462+ }
463+ }
464+ ItemKind :: MacCall ( ..) => {
469465 panic ! ( "`TyMac` should have been expanded by now" )
470466 }
471467 }
0 commit comments