@@ -42,32 +42,37 @@ crate type ExternalPaths = FxHashMap<DefId, (Vec<String>, clean::TypeKind)>;
42
42
43
43
crate struct DocContext < ' tcx > {
44
44
crate tcx : TyCtxt < ' tcx > ,
45
+ /// Name resolver. Used for intra-doc links.
46
+ ///
47
+ /// The `Rc<RefCell<...>>` wrapping is needed because that is what's returned by
48
+ /// [`Queries::expansion()`].
49
+ // FIXME: see if we can get rid of this RefCell somehow
45
50
crate resolver : Rc < RefCell < interface:: BoxedResolver > > ,
46
51
/// Used for normalization.
47
52
///
48
53
/// Most of this logic is copied from rustc_lint::late.
49
54
crate param_env : ParamEnv < ' tcx > ,
50
55
/// Later on moved into `cache`
51
- crate renderinfo : RefCell < RenderInfo > ,
56
+ crate renderinfo : RenderInfo ,
52
57
/// Later on moved through `clean::Crate` into `cache`
53
58
crate external_traits : Rc < RefCell < FxHashMap < DefId , clean:: Trait > > > ,
54
59
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
55
60
/// the same time.
56
- crate active_extern_traits : RefCell < FxHashSet < DefId > > ,
61
+ crate active_extern_traits : FxHashSet < DefId > ,
57
62
// The current set of type and lifetime substitutions,
58
63
// for expanding type aliases at the HIR level:
59
64
/// Table `DefId` of type parameter -> substituted type
60
- crate ty_substs : RefCell < FxHashMap < DefId , clean:: Type > > ,
65
+ crate ty_substs : FxHashMap < DefId , clean:: Type > ,
61
66
/// Table `DefId` of lifetime parameter -> substituted lifetime
62
- crate lt_substs : RefCell < FxHashMap < DefId , clean:: Lifetime > > ,
67
+ crate lt_substs : FxHashMap < DefId , clean:: Lifetime > ,
63
68
/// Table `DefId` of const parameter -> substituted const
64
- crate ct_substs : RefCell < FxHashMap < DefId , clean:: Constant > > ,
69
+ crate ct_substs : FxHashMap < DefId , clean:: Constant > ,
65
70
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds
66
- crate impl_trait_bounds : RefCell < FxHashMap < ImplTraitParam , Vec < clean:: GenericBound > > > ,
71
+ crate impl_trait_bounds : FxHashMap < ImplTraitParam , Vec < clean:: GenericBound > > ,
67
72
crate fake_def_ids : FxHashMap < CrateNum , DefIndex > ,
68
73
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
69
74
// FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
70
- crate generated_synthetics : RefCell < FxHashSet < ( Ty < ' tcx > , DefId ) > > ,
75
+ crate generated_synthetics : FxHashSet < ( Ty < ' tcx > , DefId ) > ,
71
76
crate auto_traits : Vec < DefId > ,
72
77
/// The options given to rustdoc that could be relevant to a pass.
73
78
crate render_options : RenderOptions ,
@@ -112,14 +117,14 @@ impl<'tcx> DocContext<'tcx> {
112
117
F : FnOnce ( & mut Self ) -> R ,
113
118
{
114
119
let ( old_tys, old_lts, old_cts) = (
115
- mem:: replace ( & mut * self . ty_substs . get_mut ( ) , ty_substs) ,
116
- mem:: replace ( & mut * self . lt_substs . get_mut ( ) , lt_substs) ,
117
- mem:: replace ( & mut * self . ct_substs . get_mut ( ) , ct_substs) ,
120
+ mem:: replace ( & mut self . ty_substs , ty_substs) ,
121
+ mem:: replace ( & mut self . lt_substs , lt_substs) ,
122
+ mem:: replace ( & mut self . ct_substs , ct_substs) ,
118
123
) ;
119
124
let r = f ( self ) ;
120
- * self . ty_substs . get_mut ( ) = old_tys;
121
- * self . lt_substs . get_mut ( ) = old_lts;
122
- * self . ct_substs . get_mut ( ) = old_cts;
125
+ self . ty_substs = old_tys;
126
+ self . lt_substs = old_lts;
127
+ self . ct_substs = old_cts;
123
128
r
124
129
}
125
130
@@ -509,7 +514,7 @@ crate fn run_global_ctxt(
509
514
param_env : ParamEnv :: empty ( ) ,
510
515
external_traits : Default :: default ( ) ,
511
516
active_extern_traits : Default :: default ( ) ,
512
- renderinfo : RefCell :: new ( renderinfo ) ,
517
+ renderinfo,
513
518
ty_substs : Default :: default ( ) ,
514
519
lt_substs : Default :: default ( ) ,
515
520
ct_substs : Default :: default ( ) ,
@@ -642,7 +647,7 @@ crate fn run_global_ctxt(
642
647
// The main crate doc comments are always collapsed.
643
648
krate. collapsed = true ;
644
649
645
- ( krate, ctxt. renderinfo . into_inner ( ) , ctxt. render_options )
650
+ ( krate, ctxt. renderinfo , ctxt. render_options )
646
651
}
647
652
648
653
/// Due to <https://github.com/rust-lang/rust/pull/73566>,
0 commit comments