X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustdoc%2Fcore.rs;h=1d55fa42a3a9bc0b3cb764ca65f9edf7e85a7c3f;hb=163b01aa140299ca5934031e5edf17cb23184941;hp=f0b3159f737a6ec2aa4f2914a1c7d955c4a6ec93;hpb=33aaead6a1bdd4b2fde50efde825d2a770d8ecb8;p=rust.git diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index f0b3159f737..1d55fa42a3a 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -31,15 +31,12 @@ use crate::clean; use crate::clean::inline::build_external_trait; use crate::clean::{AttributesExt, TraitWithExtraInfo, MAX_DEF_IDX}; -use crate::config::{Options as RustdocOptions, RenderOptions}; -use crate::config::{OutputFormat, RenderInfo}; +use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions}; use crate::formats::cache::Cache; use crate::passes::{self, Condition::*, ConditionalPass}; crate use rustc_session::config::{DebuggingOptions, Input, Options}; -crate type ExternalPaths = FxHashMap, clean::TypeKind)>; - crate struct DocContext<'tcx> { crate tcx: TyCtxt<'tcx>, /// Name resolver. Used for intra-doc links. @@ -52,8 +49,6 @@ /// /// Most of this logic is copied from rustc_lint::late. crate param_env: ParamEnv<'tcx>, - /// Later on moved into `cache` - crate renderinfo: RenderInfo, /// Later on moved through `clean::Crate` into `cache` crate external_traits: Rc>>, /// Used while populating `external_traits` to ensure we don't process the same trait twice at @@ -81,8 +76,12 @@ /// See `collect_intra_doc_links::traits_implemented_by` for more details. /// `map>` crate module_trait_cache: RefCell>>, - /// Fake empty cache used when cache is required as parameter. + /// This same cache is used throughout rustdoc, including in [`crate::html::render`]. crate cache: Cache, + /// Used by [`clean::inline`] to tell if an item has already been inlined. + crate inlined: FxHashSet, + /// Used by `calculate_doc_coverage`. + crate output_format: OutputFormat, } impl<'tcx> DocContext<'tcx> { @@ -465,7 +464,7 @@ pub(crate) fn init_lints( mut manual_passes: Vec, render_options: RenderOptions, output_format: OutputFormat, -) -> (clean::Crate, RenderInfo, RenderOptions) { +) -> (clean::Crate, RenderOptions, Cache) { // Certain queries assume that some checks were run elsewhere // (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425), // so type-check everything other than function bodies in this crate before running lints. @@ -504,17 +503,12 @@ pub(crate) fn init_lints( .collect(), }; - let mut renderinfo = RenderInfo::default(); - renderinfo.access_levels = access_levels; - renderinfo.output_format = output_format; - let mut ctxt = DocContext { tcx, resolver, param_env: ParamEnv::empty(), external_traits: Default::default(), active_extern_traits: Default::default(), - renderinfo, ty_substs: Default::default(), lt_substs: Default::default(), ct_substs: Default::default(), @@ -527,9 +521,11 @@ pub(crate) fn init_lints( .cloned() .filter(|trait_def_id| tcx.trait_is_auto(*trait_def_id)) .collect(), - render_options, module_trait_cache: RefCell::new(FxHashMap::default()), - cache: Cache::default(), + cache: Cache::new(access_levels, render_options.document_private), + inlined: FxHashSet::default(), + output_format, + render_options, }; // Small hack to force the Sized trait to be present. @@ -647,10 +643,16 @@ fn report_deprecated_attr(name: &str, diag: &rustc_errors::Handler) { ctxt.sess().abort_if_errors(); + let render_options = ctxt.render_options; + let mut cache = ctxt.cache; + krate = tcx.sess.time("create_format_cache", || { + cache.populate(krate, tcx, &render_options.extern_html_root_urls, &render_options.output) + }); + // The main crate doc comments are always collapsed. krate.collapsed = true; - (krate, ctxt.renderinfo, ctxt.render_options) + (krate, render_options, cache) } /// Due to ,