Minimize amount of fake DefIds used in rustdoc
This commit is contained in:
parent
c6dd87a6b4
commit
67d8d18b23
12 changed files with 55 additions and 90 deletions
|
|
@ -7,7 +7,7 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
|
|||
|
||||
use crate::clean;
|
||||
use crate::clean::types::{
|
||||
FakeDefId, FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
|
||||
FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
|
||||
};
|
||||
use crate::formats::cache::Cache;
|
||||
use crate::formats::item_type::ItemType;
|
||||
|
|
@ -82,7 +82,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
|
|||
defid_to_pathid.insert(defid, pathid);
|
||||
lastpathid += 1;
|
||||
|
||||
if let Some(&(ref fqp, short)) = paths.get(&defid.expect_real()) {
|
||||
if let Some(&(ref fqp, short)) = paths.get(&defid) {
|
||||
crate_paths.push((short, fqp.last().unwrap().clone()));
|
||||
Some(pathid)
|
||||
} else {
|
||||
|
|
@ -214,7 +214,7 @@ crate fn get_index_search_type<'tcx>(
|
|||
|
||||
fn get_index_type(clean_type: &clean::Type, cache: &Cache) -> RenderType {
|
||||
RenderType {
|
||||
ty: clean_type.def_id_full(cache).map(FakeDefId::new_real),
|
||||
ty: clean_type.def_id_full(cache),
|
||||
idx: None,
|
||||
name: get_index_type_name(clean_type, true).map(|s| s.as_str().to_ascii_lowercase()),
|
||||
generics: get_generics(clean_type, cache),
|
||||
|
|
@ -256,7 +256,7 @@ fn get_generics(clean_type: &clean::Type, cache: &Cache) -> Option<Vec<Generic>>
|
|||
.filter_map(|t| {
|
||||
get_index_type_name(t, false).map(|name| Generic {
|
||||
name: name.as_str().to_ascii_lowercase(),
|
||||
defid: t.def_id_full(cache).map(FakeDefId::new_real),
|
||||
defid: t.def_id_full(cache),
|
||||
idx: None,
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ crate struct IndexItem {
|
|||
crate name: String,
|
||||
crate path: String,
|
||||
crate desc: String,
|
||||
crate parent: Option<FakeDefId>,
|
||||
crate parent: Option<DefId>,
|
||||
crate parent_idx: Option<usize>,
|
||||
crate search_type: Option<IndexItemFunctionType>,
|
||||
crate aliases: Box<[String]>,
|
||||
|
|
@ -96,7 +96,7 @@ crate struct IndexItem {
|
|||
/// A type used for the search index.
|
||||
#[derive(Debug)]
|
||||
crate struct RenderType {
|
||||
ty: Option<FakeDefId>,
|
||||
ty: Option<DefId>,
|
||||
idx: Option<usize>,
|
||||
name: Option<String>,
|
||||
generics: Option<Vec<Generic>>,
|
||||
|
|
@ -128,7 +128,7 @@ impl Serialize for RenderType {
|
|||
#[derive(Debug)]
|
||||
crate struct Generic {
|
||||
name: String,
|
||||
defid: Option<FakeDefId>,
|
||||
defid: Option<DefId>,
|
||||
idx: Option<usize>,
|
||||
}
|
||||
|
||||
|
|
@ -2137,7 +2137,7 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
|
|||
"</div>",
|
||||
);
|
||||
|
||||
if let Some(implementors) = cx.cache.implementors.get(&it.def_id) {
|
||||
if let Some(implementors) = cx.cache.implementors.get(&it.def_id.expect_real()) {
|
||||
let cache = cx.cache();
|
||||
let mut res = implementors
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -642,7 +642,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
|||
// If there are methods directly on this trait object, render them here.
|
||||
render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All);
|
||||
|
||||
if let Some(implementors) = cx.cache.implementors.get(&it.def_id) {
|
||||
if let Some(implementors) = cx.cache.implementors.get(&it.def_id.expect_real()) {
|
||||
// The DefId is for the first Type found with that name. The bool is
|
||||
// if any Types with the same name but different DefId have been found.
|
||||
let mut implementor_dups: FxHashMap<Symbol, (DefId, bool)> = FxHashMap::default();
|
||||
|
|
|
|||
|
|
@ -465,8 +465,6 @@ pub(super) fn write_shared(
|
|||
// Update the list of all implementors for traits
|
||||
let dst = cx.dst.join("implementors");
|
||||
for (&did, imps) in &cx.cache.implementors {
|
||||
let did = did.expect_real();
|
||||
|
||||
// Private modules can leak through to this phase of rustdoc, which
|
||||
// could contain implementations for otherwise private types. In some
|
||||
// rare cases we could find an implementation for an item which wasn't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue