@@ -62,7 +62,7 @@ impl<'a, 'tcx> Stripper<'a, 'tcx> {
62
62
63
63
/// In case `i` is a non-hidden impl block, then we special-case it by changing the value
64
64
/// of `is_in_hidden_item` to `true` because the impl children inherit its visibility.
65
- fn recurse_in_impl ( & mut self , i : Item ) -> Item {
65
+ fn recurse_in_impl_or_exported_macro ( & mut self , i : Item ) -> Item {
66
66
let prev = mem:: replace ( & mut self . is_in_hidden_item , false ) ;
67
67
let ret = self . fold_item_recur ( i) ;
68
68
self . is_in_hidden_item = prev;
@@ -73,9 +73,17 @@ impl<'a, 'tcx> Stripper<'a, 'tcx> {
73
73
impl < ' a , ' tcx > DocFolder for Stripper < ' a , ' tcx > {
74
74
fn fold_item ( & mut self , i : Item ) -> Option < Item > {
75
75
let has_doc_hidden = i. attrs . lists ( sym:: doc) . has_word ( sym:: hidden) ;
76
- let is_impl = matches ! ( * i. kind, clean:: ImplItem ( ..) ) ;
76
+ let is_impl_or_exported_macro = match * i. kind {
77
+ clean:: ImplItem ( ..) => true ,
78
+ // If the macro has the `#[macro_export]` attribute, it means it's accessible at the
79
+ // crate level so it should be handled differently.
80
+ clean:: MacroItem ( ..) => {
81
+ i. attrs . other_attrs . iter ( ) . any ( |attr| attr. has_name ( sym:: macro_export) )
82
+ }
83
+ _ => false ,
84
+ } ;
77
85
let mut is_hidden = has_doc_hidden;
78
- if !is_impl {
86
+ if !is_impl_or_exported_macro {
79
87
is_hidden = self . is_in_hidden_item || has_doc_hidden;
80
88
if !is_hidden && i. inline_stmt_id . is_none ( ) {
81
89
// We don't need to check if it's coming from a reexport since the reexport itself was
@@ -92,8 +100,8 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
92
100
if self . update_retained {
93
101
self . retained . insert ( i. item_id ) ;
94
102
}
95
- return Some ( if is_impl {
96
- self . recurse_in_impl ( i)
103
+ return Some ( if is_impl_or_exported_macro {
104
+ self . recurse_in_impl_or_exported_macro ( i)
97
105
} else {
98
106
self . set_is_in_hidden_item_and_fold ( false , i)
99
107
} ) ;
0 commit comments