@@ -49,8 +49,6 @@ crate struct DocContext<'tcx> {
4949 ///
5050 /// Most of this logic is copied from rustc_lint::late.
5151 crate param_env : Cell < ParamEnv < ' tcx > > ,
52- /// Later on moved into `cache`
53- crate renderinfo : RefCell < RenderInfo > ,
5452 /// Later on moved through `clean::Crate` into `cache`
5553 crate external_traits : Rc < RefCell < FxHashMap < DefId , clean:: Trait > > > ,
5654 /// Used while populating `external_traits` to ensure we don't process the same trait twice at
@@ -78,8 +76,12 @@ crate struct DocContext<'tcx> {
7876 /// See `collect_intra_doc_links::traits_implemented_by` for more details.
7977 /// `map<module, set<trait>>`
8078 crate module_trait_cache : RefCell < FxHashMap < DefId , FxHashSet < DefId > > > ,
81- /// Fake empty cache used when cache is required as parameter.
82- crate cache : Cache ,
79+ /// This same cache is used throughout rustdoc, including in `render`.
80+ crate cache : RefCell < Cache > ,
81+ /// Used by `clean::inline` to tell if an item has already been inlined.
82+ crate inlined : RefCell < FxHashSet < DefId > > ,
83+ /// Used by `calculate_doc_coverage`.
84+ crate output_format : OutputFormat ,
8385}
8486
8587impl < ' tcx > DocContext < ' tcx > {
@@ -464,7 +466,7 @@ crate fn run_global_ctxt(
464466 mut manual_passes : Vec < String > ,
465467 render_options : RenderOptions ,
466468 output_format : OutputFormat ,
467- ) -> ( clean:: Crate , RenderInfo , RenderOptions ) {
469+ ) -> ( clean:: Crate , RenderOptions , Cache ) {
468470 // Certain queries assume that some checks were run elsewhere
469471 // (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425),
470472 // so type-check everything other than function bodies in this crate before running lints.
@@ -514,7 +516,6 @@ crate fn run_global_ctxt(
514516 param_env : Cell :: new ( ParamEnv :: empty ( ) ) ,
515517 external_traits : Default :: default ( ) ,
516518 active_extern_traits : Default :: default ( ) ,
517- renderinfo : RefCell :: new ( renderinfo) ,
518519 ty_substs : Default :: default ( ) ,
519520 lt_substs : Default :: default ( ) ,
520521 ct_substs : Default :: default ( ) ,
@@ -527,9 +528,11 @@ crate fn run_global_ctxt(
527528 . cloned ( )
528529 . filter ( |trait_def_id| tcx. trait_is_auto ( * trait_def_id) )
529530 . collect ( ) ,
530- render_options,
531531 module_trait_cache : RefCell :: new ( FxHashMap :: default ( ) ) ,
532- cache : Cache :: default ( ) ,
532+ cache : RefCell :: new ( Cache :: new ( renderinfo, render_options. document_private ) ) ,
533+ inlined : RefCell :: new ( FxHashSet :: default ( ) ) ,
534+ output_format,
535+ render_options,
533536 } ;
534537 debug ! ( "crate: {:?}" , tcx. hir( ) . krate( ) ) ;
535538
@@ -634,10 +637,17 @@ crate fn run_global_ctxt(
634637
635638 ctxt. sess ( ) . abort_if_errors ( ) ;
636639
640+ let render_options = ctxt. render_options ;
641+ let mut cache = ctxt. cache . into_inner ( ) ;
642+
643+ krate = tcx. sess . time ( "create_format_cache" , || {
644+ cache. populate ( krate, tcx, & render_options. extern_html_root_urls , & render_options. output )
645+ } ) ;
646+
637647 // The main crate doc comments are always collapsed.
638648 krate. collapsed = true ;
639649
640- ( krate, ctxt . renderinfo . into_inner ( ) , ctxt . render_options )
650+ ( krate, render_options , cache )
641651}
642652
643653/// Due to <https://github.com/rust-lang/rust/pull/73566>,
0 commit comments