@@ -36,19 +36,18 @@ use crate::formats::cache::Cache;
36
36
use crate :: json:: conversions:: IntoJson ;
37
37
use crate :: { clean, try_err} ;
38
38
39
- #[ derive( Clone ) ]
40
39
pub ( crate ) struct JsonRenderer < ' tcx > {
41
40
tcx : TyCtxt < ' tcx > ,
42
41
/// A mapping of IDs that contains all local items for this crate which gets output as a top
43
42
/// level field of the JSON blob.
44
- index : Rc < RefCell < FxHashMap < types:: Id , types:: Item > > > ,
43
+ index : FxHashMap < types:: Id , types:: Item > ,
45
44
/// The directory where the JSON blob should be written to.
46
45
///
47
46
/// If this is `None`, the blob will be printed to `stdout` instead.
48
47
out_dir : Option < PathBuf > ,
49
48
cache : Rc < Cache > ,
50
49
imported_items : DefIdSet ,
51
- id_interner : Rc < RefCell < ids:: IdInterner > > ,
50
+ id_interner : RefCell < ids:: IdInterner > ,
52
51
}
53
52
54
53
impl < ' tcx > JsonRenderer < ' tcx > {
@@ -197,7 +196,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
197
196
Ok ( (
198
197
JsonRenderer {
199
198
tcx,
200
- index : Rc :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
199
+ index : FxHashMap :: default ( ) ,
201
200
out_dir : if options. output_to_stdout { None } else { Some ( options. output ) } ,
202
201
cache : Rc :: new ( cache) ,
203
202
imported_items,
@@ -272,7 +271,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
272
271
| types:: ItemEnum :: Macro ( _)
273
272
| types:: ItemEnum :: ProcMacro ( _) => false ,
274
273
} ;
275
- let removed = self . index . borrow_mut ( ) . insert ( new_item. id , new_item. clone ( ) ) ;
274
+ let removed = self . index . insert ( new_item. id , new_item. clone ( ) ) ;
276
275
277
276
// FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check
278
277
// to make sure the items are unique. The main place this happens is when an item, is
@@ -295,11 +294,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
295
294
unreachable ! ( "RUN_ON_MODULE = false, should never call mod_item_in" )
296
295
}
297
296
298
- fn after_krate ( & mut self ) -> Result < ( ) , Error > {
297
+ fn after_krate ( self ) -> Result < ( ) , Error > {
299
298
debug ! ( "Done with crate" ) ;
300
299
301
300
let e = ExternalCrate { crate_num : LOCAL_CRATE } ;
302
- let index = ( * self . index ) . clone ( ) . into_inner ( ) ;
301
+ let index = self . index . clone ( ) ;
303
302
304
303
// Note that tcx.rust_target_features is inappropriate here because rustdoc tries to run for
305
304
// multiple targets: https://github.com/rust-lang/rust/pull/137632
@@ -324,7 +323,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
324
323
types:: ItemSummary {
325
324
crate_id : k. krate . as_u32 ( ) ,
326
325
path : path. iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ,
327
- kind : kind. into_json ( self ) ,
326
+ kind : kind. into_json ( & self ) ,
328
327
} ,
329
328
)
330
329
} )
0 commit comments