rustdoc: Replace FakeDefId
with new ItemId
type
This commit is contained in:
parent
6e9b3696d4
commit
43e1cdbaf9
14 changed files with 79 additions and 84 deletions
|
@ -113,7 +113,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
|||
name: None,
|
||||
attrs: Default::default(),
|
||||
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 {
|
||||
span: Span::dummy(),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
|
|
|
@ -96,7 +96,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
|||
name: None,
|
||||
attrs: Default::default(),
|
||||
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 {
|
||||
span: self.cx.tcx.def_span(impl_def_id).clean(self.cx),
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_span::hygiene::MacroKind;
|
|||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
||||
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::formats::item_type::ItemType;
|
||||
|
@ -486,7 +486,7 @@ fn build_module(
|
|||
items.push(clean::Item {
|
||||
name: None,
|
||||
attrs: box clean::Attributes::default(),
|
||||
def_id: FakeDefId::new_fake(did.krate),
|
||||
def_id: ItemId::Primitive(did.krate),
|
||||
visibility: clean::Public,
|
||||
kind: box clean::ImportItem(clean::Import::new_simple(
|
||||
item.ident.name,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::cell::RefCell;
|
||||
use std::default::Default;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::iter::FromIterator;
|
||||
|
@ -18,7 +18,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_hir as hir;
|
||||
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::{BodyId, Mutability};
|
||||
use rustc_index::vec::IndexVec;
|
||||
|
@ -48,73 +48,68 @@ use self::ItemKind::*;
|
|||
use self::SelfTy::*;
|
||||
use self::Type::*;
|
||||
|
||||
crate type FakeDefIdSet = FxHashSet<FakeDefId>;
|
||||
crate type ItemIdSet = FxHashSet<ItemId>;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
|
||||
crate enum FakeDefId {
|
||||
Real(DefId),
|
||||
Fake(DefIndex, CrateNum),
|
||||
crate enum ItemId {
|
||||
/// A "normal" item that uses a [`DefId`] for identification.
|
||||
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 {
|
||||
#[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)
|
||||
}
|
||||
|
||||
impl ItemId {
|
||||
#[inline]
|
||||
crate fn is_local(self) -> bool {
|
||||
match self {
|
||||
FakeDefId::Real(id) => id.is_local(),
|
||||
FakeDefId::Fake(_, krate) => krate == LOCAL_CRATE,
|
||||
ItemId::DefId(id) => id.is_local(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
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]
|
||||
crate fn as_real(self) -> Option<DefId> {
|
||||
match self {
|
||||
FakeDefId::Real(id) => Some(id),
|
||||
FakeDefId::Fake(_, _) => None,
|
||||
ItemId::DefId(id) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
crate fn krate(self) -> CrateNum {
|
||||
match self {
|
||||
FakeDefId::Real(id) => id.krate,
|
||||
FakeDefId::Fake(_, krate) => krate,
|
||||
ItemId::DefId(id) => id.krate,
|
||||
ItemId::Auto { trait_, .. } => trait_.krate,
|
||||
ItemId::Blanket { trait_, .. } => trait_.krate,
|
||||
ItemId::Primitive(krate) => krate,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
crate fn index(self) -> Option<DefIndex> {
|
||||
match self {
|
||||
FakeDefId::Real(id) => Some(id.index),
|
||||
FakeDefId::Fake(_, _) => None,
|
||||
ItemId::DefId(id) => Some(id.index),
|
||||
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 {
|
||||
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.
|
||||
/// E.g., struct vs enum vs function.
|
||||
crate kind: Box<ItemKind>,
|
||||
crate def_id: FakeDefId,
|
||||
crate def_id: ItemId,
|
||||
|
||||
crate cfg: Option<Arc<Cfg>>,
|
||||
}
|
||||
|
||||
// `Item` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
#[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 {
|
||||
Span::from_rustc_span(def_id.as_local().map_or_else(
|
||||
|
@ -664,7 +659,8 @@ impl Item {
|
|||
}
|
||||
|
||||
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(..))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ use std::mem;
|
|||
use std::rc::Rc;
|
||||
|
||||
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::formats::cache::Cache;
|
||||
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`].
|
||||
crate cache: Cache,
|
||||
/// 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`.
|
||||
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.
|
||||
/// (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 {
|
||||
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))
|
||||
}
|
||||
FakeDefId::Fake(_, _) => None,
|
||||
// FIXME: Can this be `Some` for `Auto` or `Blanket`?
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_middle::middle::privacy::AccessLevels;
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use crate::clean::{self, FakeDefId, GetDefId};
|
||||
use crate::clean::{self, GetDefId, ItemId};
|
||||
use crate::fold::DocFolder;
|
||||
use crate::formats::item_type::ItemType;
|
||||
use crate::formats::Impl;
|
||||
|
@ -122,7 +122,7 @@ crate struct Cache {
|
|||
/// All intra-doc links resolved so far.
|
||||
///
|
||||
/// 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`.
|
||||
|
|
|
@ -19,7 +19,7 @@ use rustc_span::def_id::CRATE_DEF_INDEX;
|
|||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
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::html::escape::Escape;
|
||||
|
@ -1181,7 +1181,7 @@ impl clean::FnDecl {
|
|||
impl clean::Visibility {
|
||||
crate fn print_with_space<'a, 'tcx: 'a>(
|
||||
self,
|
||||
item_did: FakeDefId,
|
||||
item_did: ItemId,
|
||||
cx: &'a Context<'tcx>,
|
||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||
let to_print = match self {
|
||||
|
|
|
@ -53,7 +53,7 @@ use rustc_span::symbol::{kw, sym, Symbol};
|
|||
use serde::ser::SerializeSeq;
|
||||
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::error::Error;
|
||||
use crate::formats::cache::Cache;
|
||||
|
@ -987,7 +987,7 @@ fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item) {
|
|||
#[derive(Copy, Clone)]
|
||||
enum AssocItemLink<'a> {
|
||||
Anchor(Option<&'a str>),
|
||||
GotoSource(FakeDefId, &'a FxHashSet<Symbol>),
|
||||
GotoSource(ItemId, &'a FxHashSet<Symbol>),
|
||||
}
|
||||
|
||||
impl<'a> AssocItemLink<'a> {
|
||||
|
|
|
@ -15,7 +15,7 @@ use rustc_span::Pos;
|
|||
use rustdoc_json_types::*;
|
||||
|
||||
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::json::JsonRenderer;
|
||||
use std::collections::HashSet;
|
||||
|
@ -30,7 +30,7 @@ impl JsonRenderer<'_> {
|
|||
.into_iter()
|
||||
.flatten()
|
||||
.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();
|
||||
let docs = item.attrs.collapsed_doc_value();
|
||||
|
@ -47,7 +47,7 @@ impl JsonRenderer<'_> {
|
|||
_ => from_clean_item(item, self.tcx),
|
||||
};
|
||||
Some(Item {
|
||||
id: from_def_id(def_id),
|
||||
id: from_item_id(def_id),
|
||||
crate_id: def_id.krate().as_u32(),
|
||||
name: name.map(|sym| sym.to_string()),
|
||||
span: self.convert_span(span),
|
||||
|
@ -86,7 +86,7 @@ impl JsonRenderer<'_> {
|
|||
Inherited => Visibility::Default,
|
||||
Restricted(did) if did.index == CRATE_DEF_INDEX => Visibility::Crate,
|
||||
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(),
|
||||
},
|
||||
}
|
||||
|
@ -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 {
|
||||
FakeDefId::Real(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
|
||||
// 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))),
|
||||
ItemId::DefId(did) => Id(format!("{}:{}", did.krate.as_u32(), u32::from(did.index))),
|
||||
_ => todo!("how should json ItemId's be represented?"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,7 @@ impl FromWithTcx<clean::Type> for Type {
|
|||
match ty {
|
||||
ResolvedPath { path, did, is_generic: _ } => Type::ResolvedPath {
|
||||
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))),
|
||||
param_names: Vec::new(),
|
||||
},
|
||||
|
@ -387,7 +385,7 @@ impl FromWithTcx<clean::Type> for Type {
|
|||
|
||||
Type::ResolvedPath {
|
||||
name: path.whole_name(),
|
||||
id: from_def_id(id.into()),
|
||||
id: from_item_id(id.into()),
|
||||
args: path
|
||||
.segments
|
||||
.last()
|
||||
|
@ -568,13 +566,13 @@ impl FromWithTcx<clean::Import> for Import {
|
|||
Simple(s) => Import {
|
||||
source: import.source.path.whole_name(),
|
||||
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 => Import {
|
||||
source: import.source.path.whole_name(),
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
@ -668,5 +666,5 @@ impl FromWithTcx<ItemType> for ItemKind {
|
|||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ use crate::error::Error;
|
|||
use crate::formats::cache::Cache;
|
||||
use crate::formats::FormatRenderer;
|
||||
use crate::html::render::cache::ExternalLocation;
|
||||
use crate::json::conversions::{from_def_id, IntoWithTcx};
|
||||
use crate::json::conversions::{from_item_id, IntoWithTcx};
|
||||
|
||||
#[derive(Clone)]
|
||||
crate struct JsonRenderer<'tcx> {
|
||||
|
@ -53,7 +53,7 @@ impl JsonRenderer<'tcx> {
|
|||
.map(|i| {
|
||||
let item = &i.impl_item;
|
||||
self.item(item.clone()).unwrap();
|
||||
from_def_id(item.def_id)
|
||||
from_item_id(item.def_id)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
|
@ -71,7 +71,7 @@ impl JsonRenderer<'tcx> {
|
|||
let item = &i.impl_item;
|
||||
if item.def_id.is_local() {
|
||||
self.item(item.clone()).unwrap();
|
||||
Some(from_def_id(item.def_id))
|
||||
Some(from_item_id(item.def_id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ impl JsonRenderer<'tcx> {
|
|||
let trait_item = &trait_item.trait_;
|
||||
trait_item.items.clone().into_iter().for_each(|i| self.item(i).unwrap());
|
||||
Some((
|
||||
from_def_id(id.into()),
|
||||
from_item_id(id.into()),
|
||||
types::Item {
|
||||
id: from_def_id(id.into()),
|
||||
id: from_item_id(id.into()),
|
||||
crate_id: id.krate.as_u32(),
|
||||
name: self
|
||||
.cache
|
||||
|
@ -170,7 +170,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
|||
} else if let types::ItemEnum::Enum(ref mut e) = new_item.inner {
|
||||
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
|
||||
// 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())
|
||||
.map(|(k, (path, kind))| {
|
||||
(
|
||||
from_def_id(k.into()),
|
||||
from_item_id(k.into()),
|
||||
types::ItemSummary {
|
||||
crate_id: k.krate.as_u32(),
|
||||
path,
|
||||
|
|
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> DocFolder for SyntheticImplCollector<'a, 'tcx> {
|
|||
|
||||
#[derive(Default)]
|
||||
struct ItemCollector {
|
||||
items: FxHashSet<FakeDefId>,
|
||||
items: FxHashSet<ItemId>,
|
||||
}
|
||||
|
||||
impl ItemCollector {
|
||||
|
@ -168,7 +168,7 @@ impl DocFolder for ItemCollector {
|
|||
|
||||
struct BadImplStripper {
|
||||
prims: FxHashSet<PrimitiveType>,
|
||||
items: FxHashSet<FakeDefId>,
|
||||
items: FxHashSet<ItemId>,
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use rustc_span::symbol::sym;
|
|||
use std::mem;
|
||||
|
||||
use crate::clean;
|
||||
use crate::clean::{FakeDefIdSet, Item, NestedAttributesExt};
|
||||
use crate::clean::{Item, ItemIdSet, NestedAttributesExt};
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::{strip_item, DocFolder};
|
||||
use crate::passes::{ImplStripper, Pass};
|
||||
|
@ -15,7 +15,7 @@ crate const STRIP_HIDDEN: Pass = Pass {
|
|||
|
||||
/// Strip items marked `#[doc(hidden)]`
|
||||
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
|
||||
let krate = {
|
||||
|
@ -29,7 +29,7 @@ crate fn strip_hidden(krate: clean::Crate, _: &mut DocContext<'_>) -> clean::Cra
|
|||
}
|
||||
|
||||
struct Stripper<'a> {
|
||||
retained: &'a mut FakeDefIdSet,
|
||||
retained: &'a mut ItemIdSet,
|
||||
update_retained: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::clean::{self, FakeDefIdSet};
|
||||
use crate::clean::{self, ItemIdSet};
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::passes::{ImplStripper, ImportStripper, Pass, Stripper};
|
||||
|
@ -14,7 +14,7 @@ crate const STRIP_PRIVATE: Pass = Pass {
|
|||
/// crate, specified by the `xcrate` flag.
|
||||
crate fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
|
||||
// This stripper collects all *retained* nodes.
|
||||
let mut retained = FakeDefIdSet::default();
|
||||
let mut retained = ItemIdSet::default();
|
||||
|
||||
// strip all private items
|
||||
{
|
||||
|
|
|
@ -2,11 +2,11 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_middle::middle::privacy::AccessLevels;
|
||||
use std::mem;
|
||||
|
||||
use crate::clean::{self, FakeDefIdSet, GetDefId, Item};
|
||||
use crate::clean::{self, GetDefId, Item, ItemIdSet};
|
||||
use crate::fold::{strip_item, DocFolder};
|
||||
|
||||
crate struct Stripper<'a> {
|
||||
crate retained: &'a mut FakeDefIdSet,
|
||||
crate retained: &'a mut ItemIdSet,
|
||||
crate access_levels: &'a AccessLevels<DefId>,
|
||||
crate update_retained: bool,
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
|||
|
||||
/// This stripper discards all impls which reference stripped items
|
||||
crate struct ImplStripper<'a> {
|
||||
crate retained: &'a FakeDefIdSet,
|
||||
crate retained: &'a ItemIdSet,
|
||||
}
|
||||
|
||||
impl<'a> DocFolder for ImplStripper<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue