diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 1478437cefaa3..d9f5b5bfa3ae2 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -4,9 +4,7 @@ use std::ffi::OsStr; use std::fmt; use std::path::PathBuf; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir::def_id::DefId; -use rustc_middle::middle::privacy::AccessLevels; +use rustc_data_structures::fx::FxHashMap; use rustc_session::config::{self, parse_crate_types_from_list, parse_externs, CrateType}; use rustc_session::config::{ build_codegen_options, build_debugging_options, get_cmd_lint_options, host_triple, @@ -268,20 +266,6 @@ crate struct RenderOptions { crate unstable_features: rustc_feature::UnstableFeatures, } -/// Temporary storage for data obtained during `RustdocVisitor::clean()`. -/// Later on moved into `cache`. -#[derive(Default, Clone)] -crate struct RenderInfo { - crate inlined: FxHashSet, - crate external_paths: crate::core::ExternalPaths, - crate exact_paths: FxHashMap>, - crate access_levels: AccessLevels, - crate deref_trait_did: Option, - crate deref_mut_trait_did: Option, - crate owned_box_did: Option, - crate output_format: OutputFormat, -} - impl Options { /// Parses the given command-line for options. If an error message or other early-return has /// been printed, returns `Err` with the exit code. diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index f35929da4807e..1fd1ee7b72891 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -31,15 +31,13 @@ use std::{cell::RefCell, collections::hash_map::Entry}; use crate::clean; use crate::clean::inline::build_external_trait; use crate::clean::{AttributesExt, MAX_DEF_IDX}; +use crate::config::OutputFormat; use crate::config::{Options as RustdocOptions, RenderOptions}; -use crate::config::{OutputFormat, RenderInfo}; 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>, crate resolver: Rc>, @@ -501,10 +499,6 @@ crate fn run_global_ctxt( .collect(), }; - let mut renderinfo = RenderInfo::default(); - renderinfo.access_levels = access_levels; - renderinfo.output_format = output_format; - let mut ctxt = DocContext { tcx, resolver, @@ -524,7 +518,7 @@ crate fn run_global_ctxt( .filter(|trait_def_id| tcx.trait_is_auto(*trait_def_id)) .collect(), module_trait_cache: RefCell::new(FxHashMap::default()), - cache: Cache::new(renderinfo, render_options.document_private), + cache: Cache::new(access_levels, render_options.document_private), inlined: RefCell::new(FxHashSet::default()), output_format, render_options, diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 8a2d0de792989..a5c3109e90bd6 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -10,7 +10,6 @@ use rustc_span::source_map::FileName; use rustc_span::Symbol; use crate::clean::{self, GetDefId}; -use crate::config::RenderInfo; use crate::fold::DocFolder; use crate::formats::item_type::ItemType; use crate::formats::Impl; @@ -130,32 +129,8 @@ struct CacheBuilder<'a, 'tcx> { } impl Cache { - crate fn new(render_info: RenderInfo, document_private: bool) -> Self { - // Crawl the crate to build various caches used for the output - let RenderInfo { - inlined: _, - external_paths, - exact_paths, - access_levels, - deref_trait_did, - deref_mut_trait_did, - owned_box_did, - .. - } = render_info; - - let external_paths = - external_paths.into_iter().map(|(k, (v, t))| (k, (v, ItemType::from(t)))).collect(); - - Cache { - external_paths, - exact_paths, - access_levels, - document_private, - deref_trait_did, - deref_mut_trait_did, - owned_box_did, - ..Cache::default() - } + crate fn new(access_levels: AccessLevels, document_private: bool) -> Self { + Cache { access_levels, document_private, ..Cache::default() } } crate fn populate( @@ -165,6 +140,7 @@ impl Cache { extern_html_root_urls: &BTreeMap, dst: &Path, ) -> clean::Crate { + // Crawl the crate to build various caches used for the output self.crate_version = krate.version.take(); debug!(?self.crate_version); self.traits = krate.external_traits.take();