rustdoc: Use DefId(Map,Set)
instead of FxHash(Map,Set)
Not all uses are converted, a few cases iterating through maps/sets and requiring nontrivial changes are kept.
This commit is contained in:
parent
52372f9c71
commit
68803926e0
@ -9,7 +9,7 @@
|
|||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId};
|
||||||
use rustc_hir::Mutability;
|
use rustc_hir::Mutability;
|
||||||
use rustc_metadata::creader::{CStore, LoadedMacro};
|
use rustc_metadata::creader::{CStore, LoadedMacro};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
@ -45,7 +45,7 @@ pub(crate) fn try_inline(
|
|||||||
res: Res,
|
res: Res,
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
attrs: Option<&[ast::Attribute]>,
|
attrs: Option<&[ast::Attribute]>,
|
||||||
visited: &mut FxHashSet<DefId>,
|
visited: &mut DefIdSet,
|
||||||
) -> Option<Vec<clean::Item>> {
|
) -> Option<Vec<clean::Item>> {
|
||||||
let did = res.opt_def_id()?;
|
let did = res.opt_def_id()?;
|
||||||
if did.is_local() {
|
if did.is_local() {
|
||||||
@ -163,7 +163,7 @@ pub(crate) fn try_inline_glob(
|
|||||||
cx: &mut DocContext<'_>,
|
cx: &mut DocContext<'_>,
|
||||||
res: Res,
|
res: Res,
|
||||||
current_mod: LocalDefId,
|
current_mod: LocalDefId,
|
||||||
visited: &mut FxHashSet<DefId>,
|
visited: &mut DefIdSet,
|
||||||
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
|
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
|
||||||
) -> Option<Vec<clean::Item>> {
|
) -> Option<Vec<clean::Item>> {
|
||||||
let did = res.opt_def_id()?;
|
let did = res.opt_def_id()?;
|
||||||
@ -568,11 +568,7 @@ pub(crate) fn build_impl(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_module(
|
fn build_module(cx: &mut DocContext<'_>, did: DefId, visited: &mut DefIdSet) -> clean::Module {
|
||||||
cx: &mut DocContext<'_>,
|
|
||||||
did: DefId,
|
|
||||||
visited: &mut FxHashSet<DefId>,
|
|
||||||
) -> clean::Module {
|
|
||||||
let items = build_module_items(cx, did, visited, &mut FxHashSet::default(), None);
|
let items = build_module_items(cx, did, visited, &mut FxHashSet::default(), None);
|
||||||
|
|
||||||
let span = clean::Span::new(cx.tcx.def_span(did));
|
let span = clean::Span::new(cx.tcx.def_span(did));
|
||||||
@ -582,9 +578,9 @@ fn build_module(
|
|||||||
fn build_module_items(
|
fn build_module_items(
|
||||||
cx: &mut DocContext<'_>,
|
cx: &mut DocContext<'_>,
|
||||||
did: DefId,
|
did: DefId,
|
||||||
visited: &mut FxHashSet<DefId>,
|
visited: &mut DefIdSet,
|
||||||
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
|
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
|
||||||
allowed_def_ids: Option<&FxHashSet<DefId>>,
|
allowed_def_ids: Option<&DefIdSet>,
|
||||||
) -> Vec<clean::Item> {
|
) -> Vec<clean::Item> {
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
|
||||||
use rustc_hir::PredicateOrigin;
|
use rustc_hir::PredicateOrigin;
|
||||||
use rustc_hir_analysis::hir_ty_to_ty;
|
use rustc_hir_analysis::hir_ty_to_ty;
|
||||||
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
|
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
|
||||||
@ -1528,7 +1528,7 @@ fn maybe_expand_private_type_alias<'tcx>(
|
|||||||
let hir::ItemKind::TyAlias(ty, generics) = alias else { return None };
|
let hir::ItemKind::TyAlias(ty, generics) = alias else { return None };
|
||||||
|
|
||||||
let provided_params = &path.segments.last().expect("segments were empty");
|
let provided_params = &path.segments.last().expect("segments were empty");
|
||||||
let mut substs = FxHashMap::default();
|
let mut substs = DefIdMap::default();
|
||||||
let generic_args = provided_params.args();
|
let generic_args = provided_params.args();
|
||||||
|
|
||||||
let mut indices: hir::GenericParamCount = Default::default();
|
let mut indices: hir::GenericParamCount = Default::default();
|
||||||
@ -2321,7 +2321,7 @@ fn clean_extern_crate<'tcx>(
|
|||||||
|
|
||||||
let krate_owner_def_id = krate.owner_id.to_def_id();
|
let krate_owner_def_id = krate.owner_id.to_def_id();
|
||||||
if please_inline {
|
if please_inline {
|
||||||
let mut visited = FxHashSet::default();
|
let mut visited = DefIdSet::default();
|
||||||
|
|
||||||
let res = Res::Def(DefKind::Mod, crate_def_id);
|
let res = Res::Def(DefKind::Mod, crate_def_id);
|
||||||
|
|
||||||
@ -2440,7 +2440,7 @@ fn clean_use_statement_inner<'tcx>(
|
|||||||
let path = clean_path(path, cx);
|
let path = clean_path(path, cx);
|
||||||
let inner = if kind == hir::UseKind::Glob {
|
let inner = if kind == hir::UseKind::Glob {
|
||||||
if !denied {
|
if !denied {
|
||||||
let mut visited = FxHashSet::default();
|
let mut visited = DefIdSet::default();
|
||||||
if let Some(items) =
|
if let Some(items) =
|
||||||
inline::try_inline_glob(cx, path.res, current_mod, &mut visited, inlined_names)
|
inline::try_inline_glob(cx, path.res, current_mod, &mut visited, inlined_names)
|
||||||
{
|
{
|
||||||
@ -2459,7 +2459,7 @@ fn clean_use_statement_inner<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !denied {
|
if !denied {
|
||||||
let mut visited = FxHashSet::default();
|
let mut visited = DefIdSet::default();
|
||||||
let import_def_id = import.owner_id.to_def_id();
|
let import_def_id = import.owner_id.to_def_id();
|
||||||
|
|
||||||
if let Some(mut items) = inline::try_inline(
|
if let Some(mut items) = inline::try_inline(
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
use rustc_hir::def::{Namespace, Res};
|
use rustc_hir::def::{Namespace, Res};
|
||||||
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
|
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId};
|
||||||
use rustc_hir::intravisit::{self, Visitor};
|
use rustc_hir::intravisit::{self, Visitor};
|
||||||
use rustc_hir::{HirId, Path, TraitCandidate};
|
use rustc_hir::{HirId, Path, TraitCandidate};
|
||||||
use rustc_interface::interface;
|
use rustc_interface::interface;
|
||||||
@ -60,11 +60,11 @@ pub(crate) struct DocContext<'tcx> {
|
|||||||
pub(crate) external_traits: Rc<RefCell<FxHashMap<DefId, clean::Trait>>>,
|
pub(crate) external_traits: Rc<RefCell<FxHashMap<DefId, clean::Trait>>>,
|
||||||
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
|
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
|
||||||
/// the same time.
|
/// the same time.
|
||||||
pub(crate) active_extern_traits: FxHashSet<DefId>,
|
pub(crate) active_extern_traits: DefIdSet,
|
||||||
// The current set of parameter substitutions,
|
// The current set of parameter substitutions,
|
||||||
// for expanding type aliases at the HIR level:
|
// for expanding type aliases at the HIR level:
|
||||||
/// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const
|
/// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const
|
||||||
pub(crate) substs: FxHashMap<DefId, clean::SubstParam>,
|
pub(crate) substs: DefIdMap<clean::SubstParam>,
|
||||||
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds
|
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds
|
||||||
pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>,
|
pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>,
|
||||||
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
|
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
|
||||||
@ -108,11 +108,7 @@ pub(crate) fn enter_resolver<F, R>(&self, f: F) -> R
|
|||||||
|
|
||||||
/// Call the closure with the given parameters set as
|
/// Call the closure with the given parameters set as
|
||||||
/// the substitutions for a type alias' RHS.
|
/// the substitutions for a type alias' RHS.
|
||||||
pub(crate) fn enter_alias<F, R>(
|
pub(crate) fn enter_alias<F, R>(&mut self, substs: DefIdMap<clean::SubstParam>, f: F) -> R
|
||||||
&mut self,
|
|
||||||
substs: FxHashMap<DefId, clean::SubstParam>,
|
|
||||||
f: F,
|
|
||||||
) -> R
|
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Self) -> R,
|
F: FnOnce(&mut Self) -> R,
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId};
|
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ pub(crate) struct Cache {
|
|||||||
///
|
///
|
||||||
/// The values of the map are a list of implementations and documentation
|
/// The values of the map are a list of implementations and documentation
|
||||||
/// found on that implementation.
|
/// found on that implementation.
|
||||||
pub(crate) impls: FxHashMap<DefId, Vec<Impl>>,
|
pub(crate) impls: DefIdMap<Vec<Impl>>,
|
||||||
|
|
||||||
/// Maintains a mapping of local crate `DefId`s to the fully qualified name
|
/// Maintains a mapping of local crate `DefId`s to the fully qualified name
|
||||||
/// and "short type description" of that node. This is used when generating
|
/// and "short type description" of that node. This is used when generating
|
||||||
@ -56,7 +56,7 @@ pub(crate) struct Cache {
|
|||||||
/// to the path used if the corresponding type is inlined. By
|
/// to the path used if the corresponding type is inlined. By
|
||||||
/// doing this, we can detect duplicate impls on a trait page, and only display
|
/// doing this, we can detect duplicate impls on a trait page, and only display
|
||||||
/// the impl for the inlined type.
|
/// the impl for the inlined type.
|
||||||
pub(crate) exact_paths: FxHashMap<DefId, Vec<Symbol>>,
|
pub(crate) exact_paths: DefIdMap<Vec<Symbol>>,
|
||||||
|
|
||||||
/// This map contains information about all known traits of this crate.
|
/// This map contains information about all known traits of this crate.
|
||||||
/// Implementations of a crate should inherit the documentation of the
|
/// Implementations of a crate should inherit the documentation of the
|
||||||
@ -127,7 +127,7 @@ pub(crate) struct Cache {
|
|||||||
struct CacheBuilder<'a, 'tcx> {
|
struct CacheBuilder<'a, 'tcx> {
|
||||||
cache: &'a mut Cache,
|
cache: &'a mut Cache,
|
||||||
/// This field is used to prevent duplicated impl blocks.
|
/// This field is used to prevent duplicated impl blocks.
|
||||||
impl_ids: FxHashMap<DefId, FxHashSet<DefId>>,
|
impl_ids: DefIdMap<DefIdSet>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ pub(crate) fn populate(cx: &mut DocContext<'_>, mut krate: clean::Crate) -> clea
|
|||||||
|
|
||||||
let (krate, mut impl_ids) = {
|
let (krate, mut impl_ids) = {
|
||||||
let mut cache_builder =
|
let mut cache_builder =
|
||||||
CacheBuilder { tcx, cache: &mut cx.cache, impl_ids: FxHashMap::default() };
|
CacheBuilder { tcx, cache: &mut cx.cache, impl_ids: Default::default() };
|
||||||
krate = cache_builder.fold_crate(krate);
|
krate = cache_builder.fold_crate(krate);
|
||||||
(krate, cache_builder.impl_ids)
|
(krate, cache_builder.impl_ids)
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use std::sync::mpsc::{channel, Receiver};
|
use std::sync::mpsc::{channel, Receiver};
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
@ -56,7 +56,7 @@ pub(crate) struct Context<'tcx> {
|
|||||||
pub(super) render_redirect_pages: bool,
|
pub(super) render_redirect_pages: bool,
|
||||||
/// Tracks section IDs for `Deref` targets so they match in both the main
|
/// Tracks section IDs for `Deref` targets so they match in both the main
|
||||||
/// body and the sidebar.
|
/// body and the sidebar.
|
||||||
pub(super) deref_id_map: FxHashMap<DefId, String>,
|
pub(super) deref_id_map: DefIdMap<String>,
|
||||||
/// The map used to ensure all generated 'id=' attributes are unique.
|
/// The map used to ensure all generated 'id=' attributes are unique.
|
||||||
pub(super) id_map: IdMap,
|
pub(super) id_map: IdMap,
|
||||||
/// Shared mutable state.
|
/// Shared mutable state.
|
||||||
@ -544,7 +544,7 @@ fn init(
|
|||||||
dst,
|
dst,
|
||||||
render_redirect_pages: false,
|
render_redirect_pages: false,
|
||||||
id_map,
|
id_map,
|
||||||
deref_id_map: FxHashMap::default(),
|
deref_id_map: Default::default(),
|
||||||
shared: Rc::new(scx),
|
shared: Rc::new(scx),
|
||||||
include_sources,
|
include_sources,
|
||||||
types_with_notable_traits: FxHashSet::default(),
|
types_with_notable_traits: FxHashSet::default(),
|
||||||
@ -572,7 +572,7 @@ fn make_child_renderer(&self) -> Self {
|
|||||||
current: self.current.clone(),
|
current: self.current.clone(),
|
||||||
dst: self.dst.clone(),
|
dst: self.dst.clone(),
|
||||||
render_redirect_pages: self.render_redirect_pages,
|
render_redirect_pages: self.render_redirect_pages,
|
||||||
deref_id_map: FxHashMap::default(),
|
deref_id_map: Default::default(),
|
||||||
id_map: IdMap::new(),
|
id_map: IdMap::new(),
|
||||||
shared: Rc::clone(&self.shared),
|
shared: Rc::clone(&self.shared),
|
||||||
include_sources: self.include_sources,
|
include_sources: self.include_sources,
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
use rustc_attr::{ConstStability, Deprecation, StabilityLevel};
|
use rustc_attr::{ConstStability, Deprecation, StabilityLevel};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir::def::CtorKind;
|
use rustc_hir::def::CtorKind;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::{DefId, DefIdSet};
|
||||||
use rustc_hir::Mutability;
|
use rustc_hir::Mutability;
|
||||||
use rustc_middle::middle::stability;
|
use rustc_middle::middle::stability;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
@ -1115,7 +1115,7 @@ fn render_assoc_items(
|
|||||||
it: DefId,
|
it: DefId,
|
||||||
what: AssocItemRender<'_>,
|
what: AssocItemRender<'_>,
|
||||||
) {
|
) {
|
||||||
let mut derefs = FxHashSet::default();
|
let mut derefs = DefIdSet::default();
|
||||||
derefs.insert(it);
|
derefs.insert(it);
|
||||||
render_assoc_items_inner(w, cx, containing_item, it, what, &mut derefs)
|
render_assoc_items_inner(w, cx, containing_item, it, what, &mut derefs)
|
||||||
}
|
}
|
||||||
@ -1126,7 +1126,7 @@ fn render_assoc_items_inner(
|
|||||||
containing_item: &clean::Item,
|
containing_item: &clean::Item,
|
||||||
it: DefId,
|
it: DefId,
|
||||||
what: AssocItemRender<'_>,
|
what: AssocItemRender<'_>,
|
||||||
derefs: &mut FxHashSet<DefId>,
|
derefs: &mut DefIdSet,
|
||||||
) {
|
) {
|
||||||
info!("Documenting associated items of {:?}", containing_item.name);
|
info!("Documenting associated items of {:?}", containing_item.name);
|
||||||
let shared = Rc::clone(&cx.shared);
|
let shared = Rc::clone(&cx.shared);
|
||||||
@ -1215,7 +1215,7 @@ fn render_deref_methods(
|
|||||||
impl_: &Impl,
|
impl_: &Impl,
|
||||||
container_item: &clean::Item,
|
container_item: &clean::Item,
|
||||||
deref_mut: bool,
|
deref_mut: bool,
|
||||||
derefs: &mut FxHashSet<DefId>,
|
derefs: &mut DefIdSet,
|
||||||
) {
|
) {
|
||||||
let cache = cx.cache();
|
let cache = cx.cache();
|
||||||
let deref_type = impl_.inner_impl().trait_.as_ref().unwrap();
|
let deref_type = impl_.inner_impl().trait_.as_ref().unwrap();
|
||||||
@ -2175,7 +2175,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
|
|||||||
if let Some(impl_) =
|
if let Some(impl_) =
|
||||||
v.iter().find(|i| i.trait_did() == cx.tcx().lang_items().deref_trait())
|
v.iter().find(|i| i.trait_did() == cx.tcx().lang_items().deref_trait())
|
||||||
{
|
{
|
||||||
let mut derefs = FxHashSet::default();
|
let mut derefs = DefIdSet::default();
|
||||||
derefs.insert(did);
|
derefs.insert(did);
|
||||||
sidebar_deref_methods(cx, out, impl_, v, &mut derefs, &mut used_links);
|
sidebar_deref_methods(cx, out, impl_, v, &mut derefs, &mut used_links);
|
||||||
}
|
}
|
||||||
@ -2195,7 +2195,7 @@ fn sidebar_deref_methods(
|
|||||||
out: &mut Buffer,
|
out: &mut Buffer,
|
||||||
impl_: &Impl,
|
impl_: &Impl,
|
||||||
v: &[Impl],
|
v: &[Impl],
|
||||||
derefs: &mut FxHashSet<DefId>,
|
derefs: &mut DefIdSet,
|
||||||
used_links: &mut FxHashSet<String>,
|
used_links: &mut FxHashSet<String>,
|
||||||
) {
|
) {
|
||||||
let c = cx.cache();
|
let c = cx.cache();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_hir::def_id::DefIdSet;
|
||||||
use rustc_hir::def_id::DefId;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
clean::{self, Import, ImportSource, Item},
|
clean::{self, Import, ImportSource, Item},
|
||||||
@ -14,14 +13,15 @@
|
|||||||
/// See [#100973](https://github.com/rust-lang/rust/issues/100973) and
|
/// See [#100973](https://github.com/rust-lang/rust/issues/100973) and
|
||||||
/// [#101103](https://github.com/rust-lang/rust/issues/101103) for times when
|
/// [#101103](https://github.com/rust-lang/rust/issues/101103) for times when
|
||||||
/// this information is needed.
|
/// this information is needed.
|
||||||
pub(crate) fn get_imports(krate: clean::Crate) -> (clean::Crate, FxHashSet<DefId>) {
|
pub(crate) fn get_imports(krate: clean::Crate) -> (clean::Crate, DefIdSet) {
|
||||||
let mut finder = ImportFinder { imported: FxHashSet::default() };
|
let mut finder = ImportFinder::default();
|
||||||
let krate = finder.fold_crate(krate);
|
let krate = finder.fold_crate(krate);
|
||||||
(krate, finder.imported)
|
(krate, finder.imported)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
struct ImportFinder {
|
struct ImportFinder {
|
||||||
imported: FxHashSet<DefId>,
|
imported: DefIdSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocFolder for ImportFinder {
|
impl DocFolder for ImportFinder {
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::{DefId, DefIdSet};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::def_id::LOCAL_CRATE;
|
use rustc_span::def_id::LOCAL_CRATE;
|
||||||
@ -40,7 +40,7 @@ pub(crate) struct JsonRenderer<'tcx> {
|
|||||||
/// The directory where the blob will be written to.
|
/// The directory where the blob will be written to.
|
||||||
out_path: PathBuf,
|
out_path: PathBuf,
|
||||||
cache: Rc<Cache>,
|
cache: Rc<Cache>,
|
||||||
imported_items: FxHashSet<DefId>,
|
imported_items: DefIdSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> JsonRenderer<'tcx> {
|
impl<'tcx> JsonRenderer<'tcx> {
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
use crate::formats::cache::Cache;
|
use crate::formats::cache::Cache;
|
||||||
use crate::visit::DocVisitor;
|
use crate::visit::DocVisitor;
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
|
||||||
use rustc_middle::ty::{self, DefIdTree};
|
use rustc_middle::ty::{self, DefIdTree};
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
@ -126,14 +126,14 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mut cleaner = BadImplStripper { prims, items: crate_items, cache: &cx.cache };
|
let mut cleaner = BadImplStripper { prims, items: crate_items, cache: &cx.cache };
|
||||||
let mut type_did_to_deref_target: FxHashMap<DefId, &Type> = FxHashMap::default();
|
let mut type_did_to_deref_target: DefIdMap<&Type> = DefIdMap::default();
|
||||||
|
|
||||||
// Follow all `Deref` targets of included items and recursively add them as valid
|
// Follow all `Deref` targets of included items and recursively add them as valid
|
||||||
fn add_deref_target(
|
fn add_deref_target(
|
||||||
cx: &DocContext<'_>,
|
cx: &DocContext<'_>,
|
||||||
map: &FxHashMap<DefId, &Type>,
|
map: &DefIdMap<&Type>,
|
||||||
cleaner: &mut BadImplStripper<'_>,
|
cleaner: &mut BadImplStripper<'_>,
|
||||||
targets: &mut FxHashSet<DefId>,
|
targets: &mut DefIdSet,
|
||||||
type_did: DefId,
|
type_did: DefId,
|
||||||
) {
|
) {
|
||||||
if let Some(target) = map.get(&type_did) {
|
if let Some(target) = map.get(&type_did) {
|
||||||
@ -177,7 +177,7 @@ fn add_deref_target(
|
|||||||
// `Deref` target type and the impl for type positions, this map of types is keyed by
|
// `Deref` target type and the impl for type positions, this map of types is keyed by
|
||||||
// `DefId` and for convenience uses a special cleaner that accepts `DefId`s directly.
|
// `DefId` and for convenience uses a special cleaner that accepts `DefId`s directly.
|
||||||
if cleaner.keep_impl_with_def_id(for_did.into()) {
|
if cleaner.keep_impl_with_def_id(for_did.into()) {
|
||||||
let mut targets = FxHashSet::default();
|
let mut targets = DefIdSet::default();
|
||||||
targets.insert(for_did);
|
targets.insert(for_did);
|
||||||
add_deref_target(
|
add_deref_target(
|
||||||
cx,
|
cx,
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
//! The Rust AST Visitor. Extracts useful information and massages it into a form
|
//! The Rust AST Visitor. Extracts useful information and massages it into a form
|
||||||
//! usable for `clean`.
|
//! usable for `clean`.
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::{DefId, DefIdMap};
|
||||||
use rustc_hir::Node;
|
use rustc_hir::{HirIdSet, Node, CRATE_HIR_ID};
|
||||||
use rustc_hir::CRATE_HIR_ID;
|
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
|
use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
|
||||||
use rustc_span::symbol::{kw, sym, Symbol};
|
use rustc_span::symbol::{kw, sym, Symbol};
|
||||||
@ -62,24 +61,24 @@ pub(crate) fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool
|
|||||||
|
|
||||||
pub(crate) struct RustdocVisitor<'a, 'tcx> {
|
pub(crate) struct RustdocVisitor<'a, 'tcx> {
|
||||||
cx: &'a mut core::DocContext<'tcx>,
|
cx: &'a mut core::DocContext<'tcx>,
|
||||||
view_item_stack: FxHashSet<hir::HirId>,
|
view_item_stack: HirIdSet,
|
||||||
inlining: bool,
|
inlining: bool,
|
||||||
/// Are the current module and all of its parents public?
|
/// Are the current module and all of its parents public?
|
||||||
inside_public_path: bool,
|
inside_public_path: bool,
|
||||||
exact_paths: FxHashMap<DefId, Vec<Symbol>>,
|
exact_paths: DefIdMap<Vec<Symbol>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
pub(crate) fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
|
pub(crate) fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
|
||||||
// If the root is re-exported, terminate all recursion.
|
// If the root is re-exported, terminate all recursion.
|
||||||
let mut stack = FxHashSet::default();
|
let mut stack = HirIdSet::default();
|
||||||
stack.insert(hir::CRATE_HIR_ID);
|
stack.insert(hir::CRATE_HIR_ID);
|
||||||
RustdocVisitor {
|
RustdocVisitor {
|
||||||
cx,
|
cx,
|
||||||
view_item_stack: stack,
|
view_item_stack: stack,
|
||||||
inlining: false,
|
inlining: false,
|
||||||
inside_public_path: true,
|
inside_public_path: true,
|
||||||
exact_paths: FxHashMap::default(),
|
exact_paths: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::{DefId, DefIdSet};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
|
||||||
// FIXME: this may not be exhaustive, but is sufficient for rustdocs current uses
|
// FIXME: this may not be exhaustive, but is sufficient for rustdocs current uses
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct RustdocEffectiveVisibilities {
|
pub(crate) struct RustdocEffectiveVisibilities {
|
||||||
extern_public: FxHashSet<DefId>,
|
extern_public: DefIdSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! define_method {
|
macro_rules! define_method {
|
||||||
@ -43,9 +42,9 @@ pub(crate) fn lib_embargo_visit_item(cx: &mut DocContext<'_>, def_id: DefId) {
|
|||||||
struct LibEmbargoVisitor<'a, 'tcx> {
|
struct LibEmbargoVisitor<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
// Effective visibilities for reachable nodes
|
// Effective visibilities for reachable nodes
|
||||||
extern_public: &'a mut FxHashSet<DefId>,
|
extern_public: &'a mut DefIdSet,
|
||||||
// Keeps track of already visited modules, in case a module re-exports its parent
|
// Keeps track of already visited modules, in case a module re-exports its parent
|
||||||
visited_mods: FxHashSet<DefId>,
|
visited_mods: DefIdSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LibEmbargoVisitor<'_, '_> {
|
impl LibEmbargoVisitor<'_, '_> {
|
||||||
|
Loading…
Reference in New Issue
Block a user