1
Fork 0

rustdoc: Replace FakeDefId with new ItemId type

This commit is contained in:
Justus K 2021-06-26 13:52:31 +02:00
parent 6e9b3696d4
commit 43e1cdbaf9
No known key found for this signature in database
GPG key ID: 8C62FE98A62FC462
14 changed files with 79 additions and 84 deletions

View file

@ -113,7 +113,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
name: None, name: None,
attrs: Default::default(), attrs: Default::default(),
visibility: Inherited, visibility: Inherited,
def_id: FakeDefId::new_fake(item_def_id.krate), def_id: ItemId::Auto { trait_: trait_def_id, for_: item_def_id },
kind: box ImplItem(Impl { kind: box ImplItem(Impl {
span: Span::dummy(), span: Span::dummy(),
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,

View file

@ -96,7 +96,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
name: None, name: None,
attrs: Default::default(), attrs: Default::default(),
visibility: Inherited, visibility: Inherited,
def_id: FakeDefId::new_fake(item_def_id.krate), def_id: ItemId::Blanket { trait_: trait_def_id, for_: item_def_id },
kind: box ImplItem(Impl { kind: box ImplItem(Impl {
span: self.cx.tcx.def_span(impl_def_id).clean(self.cx), span: self.cx.tcx.def_span(impl_def_id).clean(self.cx),
unsafety: hir::Unsafety::Normal, unsafety: hir::Unsafety::Normal,

View file

@ -15,7 +15,7 @@ use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use crate::clean::{ use crate::clean::{
self, utils, Attributes, AttributesExt, FakeDefId, GetDefId, NestedAttributesExt, Type, self, utils, Attributes, AttributesExt, GetDefId, ItemId, NestedAttributesExt, Type,
}; };
use crate::core::DocContext; use crate::core::DocContext;
use crate::formats::item_type::ItemType; use crate::formats::item_type::ItemType;
@ -486,7 +486,7 @@ fn build_module(
items.push(clean::Item { items.push(clean::Item {
name: None, name: None,
attrs: box clean::Attributes::default(), attrs: box clean::Attributes::default(),
def_id: FakeDefId::new_fake(did.krate), def_id: ItemId::Primitive(did.krate),
visibility: clean::Public, visibility: clean::Public,
kind: box clean::ImportItem(clean::Import::new_simple( kind: box clean::ImportItem(clean::Import::new_simple(
item.ident.name, item.ident.name,

View file

@ -1,4 +1,4 @@
use std::cell::{Cell, RefCell}; use std::cell::RefCell;
use std::default::Default; use std::default::Default;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::iter::FromIterator; use std::iter::FromIterator;
@ -18,7 +18,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::thin_vec::ThinVec; use rustc_data_structures::thin_vec::ThinVec;
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::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX};
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
use rustc_hir::{BodyId, Mutability}; use rustc_hir::{BodyId, Mutability};
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
@ -48,73 +48,68 @@ use self::ItemKind::*;
use self::SelfTy::*; use self::SelfTy::*;
use self::Type::*; use self::Type::*;
crate type FakeDefIdSet = FxHashSet<FakeDefId>; crate type ItemIdSet = FxHashSet<ItemId>;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
crate enum FakeDefId { crate enum ItemId {
Real(DefId), /// A "normal" item that uses a [`DefId`] for identification.
Fake(DefIndex, CrateNum), DefId(DefId),
/// Identifier that is used for auto traits.
Auto { trait_: DefId, for_: DefId },
/// Identifier that is used for blanket implementations.
Blanket { trait_: DefId, for_: DefId },
/// Identifier for primitive types.
Primitive(CrateNum),
} }
impl FakeDefId { impl ItemId {
#[cfg(parallel_compiler)]
crate fn new_fake(crate: CrateNum) -> Self {
unimplemented!("")
}
#[cfg(not(parallel_compiler))]
crate fn new_fake(krate: CrateNum) -> Self {
thread_local!(static FAKE_DEF_ID_COUNTER: Cell<usize> = Cell::new(0));
let id = FAKE_DEF_ID_COUNTER.with(|id| {
let tmp = id.get();
id.set(tmp + 1);
tmp
});
Self::Fake(DefIndex::from(id), krate)
}
#[inline] #[inline]
crate fn is_local(self) -> bool { crate fn is_local(self) -> bool {
match self { match self {
FakeDefId::Real(id) => id.is_local(), ItemId::DefId(id) => id.is_local(),
FakeDefId::Fake(_, krate) => krate == LOCAL_CRATE, _ => false,
} }
} }
#[inline] #[inline]
#[track_caller] #[track_caller]
crate fn expect_real(self) -> rustc_hir::def_id::DefId { crate fn expect_real(self) -> rustc_hir::def_id::DefId {
self.as_real().unwrap_or_else(|| panic!("FakeDefId::expect_real: `{:?}` isn't real", self)) self.as_real()
.unwrap_or_else(|| panic!("ItemId::expect_real: `{:?}` isn't a real ItemId", self))
} }
#[inline] #[inline]
crate fn as_real(self) -> Option<DefId> { crate fn as_real(self) -> Option<DefId> {
match self { match self {
FakeDefId::Real(id) => Some(id), ItemId::DefId(id) => Some(id),
FakeDefId::Fake(_, _) => None, _ => None,
} }
} }
#[inline] #[inline]
crate fn krate(self) -> CrateNum { crate fn krate(self) -> CrateNum {
match self { match self {
FakeDefId::Real(id) => id.krate, ItemId::DefId(id) => id.krate,
FakeDefId::Fake(_, krate) => krate, ItemId::Auto { trait_, .. } => trait_.krate,
ItemId::Blanket { trait_, .. } => trait_.krate,
ItemId::Primitive(krate) => krate,
} }
} }
#[inline] #[inline]
crate fn index(self) -> Option<DefIndex> { crate fn index(self) -> Option<DefIndex> {
match self { match self {
FakeDefId::Real(id) => Some(id.index), ItemId::DefId(id) => Some(id.index),
FakeDefId::Fake(_, _) => None, ItemId::Auto { trait_, .. } => Some(trait_.index),
ItemId::Blanket { trait_, .. } => Some(trait_.index),
ItemId::Primitive(..) => None,
} }
} }
} }
impl From<DefId> for FakeDefId { impl From<DefId> for ItemId {
fn from(id: DefId) -> Self { fn from(id: DefId) -> Self {
Self::Real(id) Self::DefId(id)
} }
} }
@ -338,14 +333,14 @@ crate struct Item {
/// Information about this item that is specific to what kind of item it is. /// Information about this item that is specific to what kind of item it is.
/// E.g., struct vs enum vs function. /// E.g., struct vs enum vs function.
crate kind: Box<ItemKind>, crate kind: Box<ItemKind>,
crate def_id: FakeDefId, crate def_id: ItemId,
crate cfg: Option<Arc<Cfg>>, crate cfg: Option<Arc<Cfg>>,
} }
// `Item` is used a lot. Make sure it doesn't unintentionally get bigger. // `Item` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Item, 48); rustc_data_structures::static_assert_size!(Item, 56);
crate fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span { crate fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
Span::from_rustc_span(def_id.as_local().map_or_else( Span::from_rustc_span(def_id.as_local().map_or_else(
@ -664,7 +659,8 @@ impl Item {
} }
crate fn is_fake(&self) -> bool { crate fn is_fake(&self) -> bool {
matches!(self.def_id, FakeDefId::Fake(_, _)) // FIXME: Find a better way to handle this
!matches!(self.def_id, ItemId::DefId(..))
} }
} }

View file

@ -30,7 +30,7 @@ use std::mem;
use std::rc::Rc; use std::rc::Rc;
use crate::clean::inline::build_external_trait; use crate::clean::inline::build_external_trait;
use crate::clean::{self, FakeDefId, TraitWithExtraInfo}; use crate::clean::{self, ItemId, TraitWithExtraInfo};
use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions}; use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions};
use crate::formats::cache::Cache; use crate::formats::cache::Cache;
use crate::passes::{self, Condition::*, ConditionalPass}; use crate::passes::{self, Condition::*, ConditionalPass};
@ -78,7 +78,7 @@ crate struct DocContext<'tcx> {
/// This same cache is used throughout rustdoc, including in [`crate::html::render`]. /// This same cache is used throughout rustdoc, including in [`crate::html::render`].
crate cache: Cache, crate cache: Cache,
/// Used by [`clean::inline`] to tell if an item has already been inlined. /// Used by [`clean::inline`] to tell if an item has already been inlined.
crate inlined: FxHashSet<FakeDefId>, crate inlined: FxHashSet<ItemId>,
/// Used by `calculate_doc_coverage`. /// Used by `calculate_doc_coverage`.
crate output_format: OutputFormat, crate output_format: OutputFormat,
} }
@ -128,12 +128,13 @@ impl<'tcx> DocContext<'tcx> {
/// Like `hir().local_def_id_to_hir_id()`, but skips calling it on fake DefIds. /// Like `hir().local_def_id_to_hir_id()`, but skips calling it on fake DefIds.
/// (This avoids a slice-index-out-of-bounds panic.) /// (This avoids a slice-index-out-of-bounds panic.)
crate fn as_local_hir_id(tcx: TyCtxt<'_>, def_id: FakeDefId) -> Option<HirId> { crate fn as_local_hir_id(tcx: TyCtxt<'_>, def_id: ItemId) -> Option<HirId> {
match def_id { match def_id {
FakeDefId::Real(real_id) => { ItemId::DefId(real_id) => {
real_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id)) real_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
} }
FakeDefId::Fake(_, _) => None, // FIXME: Can this be `Some` for `Auto` or `Blanket`?
_ => None,
} }
} }
} }

View file

@ -8,7 +8,7 @@ use rustc_middle::middle::privacy::AccessLevels;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use crate::clean::{self, FakeDefId, GetDefId}; use crate::clean::{self, GetDefId, ItemId};
use crate::fold::DocFolder; use crate::fold::DocFolder;
use crate::formats::item_type::ItemType; use crate::formats::item_type::ItemType;
use crate::formats::Impl; use crate::formats::Impl;
@ -122,7 +122,7 @@ crate struct Cache {
/// All intra-doc links resolved so far. /// All intra-doc links resolved so far.
/// ///
/// Links are indexed by the DefId of the item they document. /// Links are indexed by the DefId of the item they document.
crate intra_doc_links: BTreeMap<FakeDefId, Vec<clean::ItemLink>>, crate intra_doc_links: BTreeMap<ItemId, Vec<clean::ItemLink>>,
} }
/// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`. /// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`.

View file

@ -19,7 +19,7 @@ use rustc_span::def_id::CRATE_DEF_INDEX;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use crate::clean::{ use crate::clean::{
self, utils::find_nearest_parent_module, ExternalCrate, FakeDefId, GetDefId, PrimitiveType, self, utils::find_nearest_parent_module, ExternalCrate, GetDefId, ItemId, PrimitiveType,
}; };
use crate::formats::item_type::ItemType; use crate::formats::item_type::ItemType;
use crate::html::escape::Escape; use crate::html::escape::Escape;
@ -1181,7 +1181,7 @@ impl clean::FnDecl {
impl clean::Visibility { impl clean::Visibility {
crate fn print_with_space<'a, 'tcx: 'a>( crate fn print_with_space<'a, 'tcx: 'a>(
self, self,
item_did: FakeDefId, item_did: ItemId,
cx: &'a Context<'tcx>, cx: &'a Context<'tcx>,
) -> impl fmt::Display + 'a + Captures<'tcx> { ) -> impl fmt::Display + 'a + Captures<'tcx> {
let to_print = match self { let to_print = match self {

View file

@ -53,7 +53,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
use serde::ser::SerializeSeq; use serde::ser::SerializeSeq;
use serde::{Serialize, Serializer}; use serde::{Serialize, Serializer};
use crate::clean::{self, FakeDefId, GetDefId, RenderedLink, SelfTy}; use crate::clean::{self, GetDefId, ItemId, RenderedLink, SelfTy};
use crate::docfs::PathError; use crate::docfs::PathError;
use crate::error::Error; use crate::error::Error;
use crate::formats::cache::Cache; use crate::formats::cache::Cache;
@ -987,7 +987,7 @@ fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item) {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
enum AssocItemLink<'a> { enum AssocItemLink<'a> {
Anchor(Option<&'a str>), Anchor(Option<&'a str>),
GotoSource(FakeDefId, &'a FxHashSet<Symbol>), GotoSource(ItemId, &'a FxHashSet<Symbol>),
} }
impl<'a> AssocItemLink<'a> { impl<'a> AssocItemLink<'a> {

View file

@ -15,7 +15,7 @@ use rustc_span::Pos;
use rustdoc_json_types::*; use rustdoc_json_types::*;
use crate::clean::utils::print_const_expr; use crate::clean::utils::print_const_expr;
use crate::clean::{self, FakeDefId}; use crate::clean::{self, ItemId};
use crate::formats::item_type::ItemType; use crate::formats::item_type::ItemType;
use crate::json::JsonRenderer; use crate::json::JsonRenderer;
use std::collections::HashSet; use std::collections::HashSet;
@ -30,7 +30,7 @@ impl JsonRenderer<'_> {
.into_iter() .into_iter()
.flatten() .flatten()
.filter_map(|clean::ItemLink { link, did, .. }| { .filter_map(|clean::ItemLink { link, did, .. }| {
did.map(|did| (link.clone(), from_def_id(did.into()))) did.map(|did| (link.clone(), from_item_id(did.into())))
}) })
.collect(); .collect();
let docs = item.attrs.collapsed_doc_value(); let docs = item.attrs.collapsed_doc_value();
@ -47,7 +47,7 @@ impl JsonRenderer<'_> {
_ => from_clean_item(item, self.tcx), _ => from_clean_item(item, self.tcx),
}; };
Some(Item { Some(Item {
id: from_def_id(def_id), id: from_item_id(def_id),
crate_id: def_id.krate().as_u32(), crate_id: def_id.krate().as_u32(),
name: name.map(|sym| sym.to_string()), name: name.map(|sym| sym.to_string()),
span: self.convert_span(span), span: self.convert_span(span),
@ -86,7 +86,7 @@ impl JsonRenderer<'_> {
Inherited => Visibility::Default, Inherited => Visibility::Default,
Restricted(did) if did.index == CRATE_DEF_INDEX => Visibility::Crate, Restricted(did) if did.index == CRATE_DEF_INDEX => Visibility::Crate,
Restricted(did) => Visibility::Restricted { Restricted(did) => Visibility::Restricted {
parent: from_def_id(did.into()), parent: from_item_id(did.into()),
path: self.tcx.def_path(did).to_string_no_crate_verbose(), path: self.tcx.def_path(did).to_string_no_crate_verbose(),
}, },
} }
@ -170,12 +170,10 @@ impl FromWithTcx<clean::TypeBindingKind> for TypeBindingKind {
} }
} }
crate fn from_def_id(did: FakeDefId) -> Id { crate fn from_item_id(did: ItemId) -> Id {
match did { match did {
FakeDefId::Real(did) => Id(format!("{}:{}", did.krate.as_u32(), u32::from(did.index))), ItemId::DefId(did) => Id(format!("{}:{}", did.krate.as_u32(), u32::from(did.index))),
// We need to differentiate real and fake ids, because the indices might overlap for fake _ => todo!("how should json ItemId's be represented?"),
// and real DefId's, which would cause two different Id's treated as they were the same.
FakeDefId::Fake(idx, krate) => Id(format!("F{}:{}", krate.as_u32(), u32::from(idx))),
} }
} }
@ -375,7 +373,7 @@ impl FromWithTcx<clean::Type> for Type {
match ty { match ty {
ResolvedPath { path, did, is_generic: _ } => Type::ResolvedPath { ResolvedPath { path, did, is_generic: _ } => Type::ResolvedPath {
name: path.whole_name(), name: path.whole_name(),
id: from_def_id(did.into()), id: from_item_id(did.into()),
args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))), args: path.segments.last().map(|args| Box::new(args.clone().args.into_tcx(tcx))),
param_names: Vec::new(), param_names: Vec::new(),
}, },
@ -387,7 +385,7 @@ impl FromWithTcx<clean::Type> for Type {
Type::ResolvedPath { Type::ResolvedPath {
name: path.whole_name(), name: path.whole_name(),
id: from_def_id(id.into()), id: from_item_id(id.into()),
args: path args: path
.segments .segments
.last() .last()
@ -568,13 +566,13 @@ impl FromWithTcx<clean::Import> for Import {
Simple(s) => Import { Simple(s) => Import {
source: import.source.path.whole_name(), source: import.source.path.whole_name(),
name: s.to_string(), name: s.to_string(),
id: import.source.did.map(FakeDefId::from).map(from_def_id), id: import.source.did.map(ItemId::from).map(from_item_id),
glob: false, glob: false,
}, },
Glob => Import { Glob => Import {
source: import.source.path.whole_name(), source: import.source.path.whole_name(),
name: import.source.path.last_name().to_string(), name: import.source.path.last_name().to_string(),
id: import.source.did.map(FakeDefId::from).map(from_def_id), id: import.source.did.map(ItemId::from).map(from_item_id),
glob: true, glob: true,
}, },
} }
@ -668,5 +666,5 @@ impl FromWithTcx<ItemType> for ItemKind {
} }
fn ids(items: impl IntoIterator<Item = clean::Item>) -> Vec<Id> { fn ids(items: impl IntoIterator<Item = clean::Item>) -> Vec<Id> {
items.into_iter().filter(|x| !x.is_stripped()).map(|i| from_def_id(i.def_id)).collect() items.into_iter().filter(|x| !x.is_stripped()).map(|i| from_item_id(i.def_id)).collect()
} }

View file

@ -25,7 +25,7 @@ use crate::error::Error;
use crate::formats::cache::Cache; use crate::formats::cache::Cache;
use crate::formats::FormatRenderer; use crate::formats::FormatRenderer;
use crate::html::render::cache::ExternalLocation; use crate::html::render::cache::ExternalLocation;
use crate::json::conversions::{from_def_id, IntoWithTcx}; use crate::json::conversions::{from_item_id, IntoWithTcx};
#[derive(Clone)] #[derive(Clone)]
crate struct JsonRenderer<'tcx> { crate struct JsonRenderer<'tcx> {
@ -53,7 +53,7 @@ impl JsonRenderer<'tcx> {
.map(|i| { .map(|i| {
let item = &i.impl_item; let item = &i.impl_item;
self.item(item.clone()).unwrap(); self.item(item.clone()).unwrap();
from_def_id(item.def_id) from_item_id(item.def_id)
}) })
.collect() .collect()
}) })
@ -71,7 +71,7 @@ impl JsonRenderer<'tcx> {
let item = &i.impl_item; let item = &i.impl_item;
if item.def_id.is_local() { if item.def_id.is_local() {
self.item(item.clone()).unwrap(); self.item(item.clone()).unwrap();
Some(from_def_id(item.def_id)) Some(from_item_id(item.def_id))
} else { } else {
None None
} }
@ -91,9 +91,9 @@ impl JsonRenderer<'tcx> {
let trait_item = &trait_item.trait_; let trait_item = &trait_item.trait_;
trait_item.items.clone().into_iter().for_each(|i| self.item(i).unwrap()); trait_item.items.clone().into_iter().for_each(|i| self.item(i).unwrap());
Some(( Some((
from_def_id(id.into()), from_item_id(id.into()),
types::Item { types::Item {
id: from_def_id(id.into()), id: from_item_id(id.into()),
crate_id: id.krate.as_u32(), crate_id: id.krate.as_u32(),
name: self name: self
.cache .cache
@ -170,7 +170,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
} else if let types::ItemEnum::Enum(ref mut e) = new_item.inner { } else if let types::ItemEnum::Enum(ref mut e) = new_item.inner {
e.impls = self.get_impls(id.expect_real()) e.impls = self.get_impls(id.expect_real())
} }
let removed = self.index.borrow_mut().insert(from_def_id(id), new_item.clone()); let removed = self.index.borrow_mut().insert(from_item_id(id), new_item.clone());
// FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check // FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check
// to make sure the items are unique. The main place this happens is when an item, is // to make sure the items are unique. The main place this happens is when an item, is
@ -207,7 +207,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
.chain(self.cache.external_paths.clone().into_iter()) .chain(self.cache.external_paths.clone().into_iter())
.map(|(k, (path, kind))| { .map(|(k, (path, kind))| {
( (
from_def_id(k.into()), from_item_id(k.into()),
types::ItemSummary { types::ItemSummary {
crate_id: k.krate.as_u32(), crate_id: k.krate.as_u32(),
path, path,

View file

@ -149,7 +149,7 @@ impl<'a, 'tcx> DocFolder for SyntheticImplCollector<'a, 'tcx> {
#[derive(Default)] #[derive(Default)]
struct ItemCollector { struct ItemCollector {
items: FxHashSet<FakeDefId>, items: FxHashSet<ItemId>,
} }
impl ItemCollector { impl ItemCollector {
@ -168,7 +168,7 @@ impl DocFolder for ItemCollector {
struct BadImplStripper { struct BadImplStripper {
prims: FxHashSet<PrimitiveType>, prims: FxHashSet<PrimitiveType>,
items: FxHashSet<FakeDefId>, items: FxHashSet<ItemId>,
} }
impl BadImplStripper { impl BadImplStripper {
@ -185,7 +185,7 @@ impl BadImplStripper {
} }
} }
fn keep_impl_with_def_id(&self, did: FakeDefId) -> bool { fn keep_impl_with_def_id(&self, did: ItemId) -> bool {
self.items.contains(&did) self.items.contains(&did)
} }
} }

View file

@ -2,7 +2,7 @@ use rustc_span::symbol::sym;
use std::mem; use std::mem;
use crate::clean; use crate::clean;
use crate::clean::{FakeDefIdSet, Item, NestedAttributesExt}; use crate::clean::{Item, ItemIdSet, NestedAttributesExt};
use crate::core::DocContext; use crate::core::DocContext;
use crate::fold::{strip_item, DocFolder}; use crate::fold::{strip_item, DocFolder};
use crate::passes::{ImplStripper, Pass}; use crate::passes::{ImplStripper, Pass};
@ -15,7 +15,7 @@ crate const STRIP_HIDDEN: Pass = Pass {
/// Strip items marked `#[doc(hidden)]` /// Strip items marked `#[doc(hidden)]`
crate fn strip_hidden(krate: clean::Crate, _: &mut DocContext<'_>) -> clean::Crate { crate fn strip_hidden(krate: clean::Crate, _: &mut DocContext<'_>) -> clean::Crate {
let mut retained = FakeDefIdSet::default(); let mut retained = ItemIdSet::default();
// strip all #[doc(hidden)] items // strip all #[doc(hidden)] items
let krate = { let krate = {
@ -29,7 +29,7 @@ crate fn strip_hidden(krate: clean::Crate, _: &mut DocContext<'_>) -> clean::Cra
} }
struct Stripper<'a> { struct Stripper<'a> {
retained: &'a mut FakeDefIdSet, retained: &'a mut ItemIdSet,
update_retained: bool, update_retained: bool,
} }

View file

@ -1,4 +1,4 @@
use crate::clean::{self, FakeDefIdSet}; use crate::clean::{self, ItemIdSet};
use crate::core::DocContext; use crate::core::DocContext;
use crate::fold::DocFolder; use crate::fold::DocFolder;
use crate::passes::{ImplStripper, ImportStripper, Pass, Stripper}; use crate::passes::{ImplStripper, ImportStripper, Pass, Stripper};
@ -14,7 +14,7 @@ crate const STRIP_PRIVATE: Pass = Pass {
/// crate, specified by the `xcrate` flag. /// crate, specified by the `xcrate` flag.
crate fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate { crate fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
// This stripper collects all *retained* nodes. // This stripper collects all *retained* nodes.
let mut retained = FakeDefIdSet::default(); let mut retained = ItemIdSet::default();
// strip all private items // strip all private items
{ {

View file

@ -2,11 +2,11 @@ use rustc_hir::def_id::DefId;
use rustc_middle::middle::privacy::AccessLevels; use rustc_middle::middle::privacy::AccessLevels;
use std::mem; use std::mem;
use crate::clean::{self, FakeDefIdSet, GetDefId, Item}; use crate::clean::{self, GetDefId, Item, ItemIdSet};
use crate::fold::{strip_item, DocFolder}; use crate::fold::{strip_item, DocFolder};
crate struct Stripper<'a> { crate struct Stripper<'a> {
crate retained: &'a mut FakeDefIdSet, crate retained: &'a mut ItemIdSet,
crate access_levels: &'a AccessLevels<DefId>, crate access_levels: &'a AccessLevels<DefId>,
crate update_retained: bool, crate update_retained: bool,
} }
@ -116,7 +116,7 @@ impl<'a> DocFolder for Stripper<'a> {
/// This stripper discards all impls which reference stripped items /// This stripper discards all impls which reference stripped items
crate struct ImplStripper<'a> { crate struct ImplStripper<'a> {
crate retained: &'a FakeDefIdSet, crate retained: &'a ItemIdSet,
} }
impl<'a> DocFolder for ImplStripper<'a> { impl<'a> DocFolder for ImplStripper<'a> {