@@ -140,6 +140,7 @@ struct CacheBuilder<'a, 'tcx> {
140140 /// This field is used to prevent duplicated impl blocks.
141141 impl_ids : DefIdMap < DefIdSet > ,
142142 tcx : TyCtxt < ' tcx > ,
143+ is_json_output : bool ,
143144}
144145
145146impl Cache {
@@ -184,8 +185,13 @@ impl Cache {
184185 }
185186
186187 let ( krate, mut impl_ids) = {
187- let mut cache_builder =
188- CacheBuilder { tcx, cache : & mut cx. cache , impl_ids : Default :: default ( ) } ;
188+ let is_json_output = cx. is_json_output ( ) ;
189+ let mut cache_builder = CacheBuilder {
190+ tcx,
191+ cache : & mut cx. cache ,
192+ impl_ids : Default :: default ( ) ,
193+ is_json_output,
194+ } ;
189195 krate = cache_builder. fold_crate ( krate) ;
190196 ( krate, cache_builder. impl_ids )
191197 } ;
@@ -307,12 +313,13 @@ impl DocFolder for CacheBuilder<'_, '_> {
307313 | clean:: ProcMacroItem ( ..)
308314 | clean:: VariantItem ( ..) => {
309315 use rustc_data_structures:: fx:: IndexEntry as Entry ;
310- if !self . cache . stripped_mod
311- && !matches ! (
312- item. stability. map( |stab| stab. level) ,
313- Some ( StabilityLevel :: Stable { allowed_through_unstable_modules: true , .. } )
314- )
315- {
316+
317+ let skip_because_unstable = matches ! (
318+ item. stability. map( |stab| stab. level) ,
319+ Some ( StabilityLevel :: Stable { allowed_through_unstable_modules: true , .. } )
320+ ) ;
321+
322+ if ( !self . cache . stripped_mod && !skip_because_unstable) || self . is_json_output {
316323 // Re-exported items mean that the same id can show up twice
317324 // in the rustdoc ast that we're looking at. We know,
318325 // however, that a re-exported item doesn't show up in the
0 commit comments