Skip to content

Commit

Permalink
Remove unused RenderInfo struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Feb 22, 2021
1 parent 3c785be commit 23ca02d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 52 deletions.
18 changes: 1 addition & 17 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<DefId>,
crate external_paths: crate::core::ExternalPaths,
crate exact_paths: FxHashMap<DefId, Vec<String>>,
crate access_levels: AccessLevels<DefId>,
crate deref_trait_did: Option<DefId>,
crate deref_mut_trait_did: Option<DefId>,
crate owned_box_did: Option<DefId>,
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.
Expand Down
10 changes: 2 additions & 8 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefId, (Vec<String>, clean::TypeKind)>;

crate struct DocContext<'tcx> {
crate tcx: TyCtxt<'tcx>,
crate resolver: Rc<RefCell<interface::BoxedResolver>>,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
30 changes: 3 additions & 27 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DefId>, document_private: bool) -> Self {
Cache { access_levels, document_private, ..Cache::default() }
}

crate fn populate(
Expand All @@ -165,6 +140,7 @@ impl Cache {
extern_html_root_urls: &BTreeMap<String, String>,
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();
Expand Down

0 comments on commit 23ca02d

Please sign in to comment.