@@ -43,7 +43,16 @@ impl JsonRenderer<'_> {
43
43
let span = item. span ( self . tcx ) ;
44
44
let clean:: Item { name, attrs : _, kind : _, visibility, item_id, cfg : _ } = item;
45
45
let inner = match * item. kind {
46
- clean:: StrippedItem ( _) | clean:: KeywordItem ( _) => return None ,
46
+ clean:: KeywordItem ( _) => return None ,
47
+ clean:: StrippedItem ( ref inner) => {
48
+ match & * * inner {
49
+ // We document non-empty stripped modules as with `Module::is_stripped` set to
50
+ // `true`, to prevent contained items from being orphaned for downstream users,
51
+ // as JSON does no inlining.
52
+ clean:: ModuleItem ( m) if !m. items . is_empty ( ) => from_clean_item ( item, self . tcx ) ,
53
+ _ => return None ,
54
+ }
55
+ }
47
56
_ => from_clean_item ( item, self . tcx ) ,
48
57
} ;
49
58
Some ( Item {
@@ -220,7 +229,9 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
220
229
let header = item. fn_header ( tcx) ;
221
230
222
231
match * item. kind {
223
- ModuleItem ( m) => ItemEnum :: Module ( Module { is_crate, items : ids ( m. items , tcx) } ) ,
232
+ ModuleItem ( m) => {
233
+ ItemEnum :: Module ( Module { is_crate, items : ids ( m. items , tcx) , is_stripped : false } )
234
+ }
224
235
ImportItem ( i) => ItemEnum :: Import ( i. into_tcx ( tcx) ) ,
225
236
StructItem ( s) => ItemEnum :: Struct ( s. into_tcx ( tcx) ) ,
226
237
UnionItem ( u) => ItemEnum :: Union ( u. into_tcx ( tcx) ) ,
@@ -257,8 +268,19 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
257
268
bounds : b. into_iter ( ) . map ( |x| x. into_tcx ( tcx) ) . collect ( ) ,
258
269
default : Some ( t. item_type . unwrap_or ( t. type_ ) . into_tcx ( tcx) ) ,
259
270
} ,
260
- // `convert_item` early returns `None` for striped items and keywords.
261
- StrippedItem ( _) | KeywordItem ( _) => unreachable ! ( ) ,
271
+ // `convert_item` early returns `None` for stripped items and keywords.
272
+ KeywordItem ( _) => unreachable ! ( ) ,
273
+ StrippedItem ( inner) => {
274
+ match * inner {
275
+ ModuleItem ( m) => ItemEnum :: Module ( Module {
276
+ is_crate,
277
+ items : ids ( m. items , tcx) ,
278
+ is_stripped : true ,
279
+ } ) ,
280
+ // `convert_item` early returns `None` for stripped items we're not including
281
+ _ => unreachable ! ( ) ,
282
+ }
283
+ }
262
284
ExternCrateItem { ref src } => ItemEnum :: ExternCrate {
263
285
name : name. as_ref ( ) . unwrap ( ) . to_string ( ) ,
264
286
rename : src. map ( |x| x. to_string ( ) ) ,
0 commit comments