Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused RenderInfo struct
  • Loading branch information
jyn514 committed Mar 1, 2021
commit 163b01aa140299ca5934031e5edf17cb23184941
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
11 changes: 2 additions & 9 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ use std::{cell::RefCell, collections::hash_map::Entry};
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<DefId, (Vec<String>, clean::TypeKind)>;

crate struct DocContext<'tcx> {
crate tcx: TyCtxt<'tcx>,
/// Name resolver. Used for intra-doc links.
Expand Down Expand Up @@ -506,10 +503,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 @@ -529,7 +522,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: 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 @@ -11,7 +11,6 @@ use rustc_span::symbol::sym;
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 @@ -131,32 +130,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() }
}

/// Populates the `Cache` with more data. The returned `Crate` will be missing some data that was
Expand All @@ -168,6 +143,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