@@ -6,6 +6,7 @@ use std::mem;
6
6
use crate :: clean:: { self , Item , ItemId , ItemIdSet } ;
7
7
use crate :: fold:: { strip_item, DocFolder } ;
8
8
use crate :: formats:: cache:: Cache ;
9
+ use crate :: visit_ast:: inherits_doc_hidden;
9
10
use crate :: visit_lib:: RustdocEffectiveVisibilities ;
10
11
11
12
pub ( crate ) struct Stripper < ' a , ' tcx > {
@@ -151,6 +152,7 @@ pub(crate) struct ImplStripper<'a, 'tcx> {
151
152
pub ( crate ) cache : & ' a Cache ,
152
153
pub ( crate ) is_json_output : bool ,
153
154
pub ( crate ) document_private : bool ,
155
+ pub ( crate ) document_hidden : bool ,
154
156
}
155
157
156
158
impl < ' a > ImplStripper < ' a , ' _ > {
@@ -162,7 +164,13 @@ impl<'a> ImplStripper<'a, '_> {
162
164
// If the "for" item is exported and the impl block isn't `#[doc(hidden)]`, then we
163
165
// need to keep it.
164
166
self . cache . effective_visibilities . is_exported ( self . tcx , for_def_id)
165
- && !item. is_doc_hidden ( )
167
+ && ( self . document_hidden
168
+ || ( ( !item. is_doc_hidden ( )
169
+ && for_def_id
170
+ . as_local ( )
171
+ . map ( |def_id| !inherits_doc_hidden ( self . tcx , def_id, None ) )
172
+ . unwrap_or ( true ) )
173
+ || self . cache . inlined_items . contains ( & for_def_id) ) )
166
174
} else {
167
175
false
168
176
}
@@ -231,6 +239,7 @@ impl<'a> DocFolder for ImplStripper<'a, '_> {
231
239
pub ( crate ) struct ImportStripper < ' tcx > {
232
240
pub ( crate ) tcx : TyCtxt < ' tcx > ,
233
241
pub ( crate ) is_json_output : bool ,
242
+ pub ( crate ) document_hidden : bool ,
234
243
}
235
244
236
245
impl < ' tcx > ImportStripper < ' tcx > {
@@ -247,8 +256,12 @@ impl<'tcx> ImportStripper<'tcx> {
247
256
impl < ' tcx > DocFolder for ImportStripper < ' tcx > {
248
257
fn fold_item ( & mut self , i : Item ) -> Option < Item > {
249
258
match * i. kind {
250
- clean:: ImportItem ( imp) if self . import_should_be_hidden ( & i, & imp) => None ,
251
- clean:: ImportItem ( _) if i. is_doc_hidden ( ) => None ,
259
+ clean:: ImportItem ( imp)
260
+ if !self . document_hidden && self . import_should_be_hidden ( & i, & imp) =>
261
+ {
262
+ None
263
+ }
264
+ // clean::ImportItem(_) if !self.document_hidden && i.is_doc_hidden() => None,
252
265
clean:: ExternCrateItem { .. } | clean:: ImportItem ( ..)
253
266
if i. visibility ( self . tcx ) != Some ( Visibility :: Public ) =>
254
267
{
0 commit comments