diff options
| author | Justus K <justus.k@protonmail.com> | 2021-04-29 21:36:54 +0200 |
|---|---|---|
| committer | Justus K <justus.k@protonmail.com> | 2021-05-04 19:34:12 +0200 |
| commit | b6120bfb354c1c1c9fdfe7ff03daa5550a8706fc (patch) | |
| tree | 4a59bc13db3194abacf0c3a34329b7886c11e8ce /src/librustdoc/html/render/mod.rs | |
| parent | 7a0f1781d04662041db5deaef89598a8edd53717 (diff) | |
| download | rust-b6120bfb354c1c1c9fdfe7ff03daa5550a8706fc.tar.gz rust-b6120bfb354c1c1c9fdfe7ff03daa5550a8706fc.zip | |
Add type to differentiate between fake and real DefId's
Diffstat (limited to 'src/librustdoc/html/render/mod.rs')
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 1271b54debd..ea57831c0e5 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -54,7 +54,7 @@ use rustc_span::symbol::{kw, sym, Symbol}; use serde::ser::SerializeSeq; use serde::{Serialize, Serializer}; -use crate::clean::{self, GetDefId, RenderedLink, SelfTy}; +use crate::clean::{self, FakeDefId, GetDefId, RenderedLink, SelfTy}; use crate::docfs::PathError; use crate::error::Error; use crate::formats::cache::Cache; @@ -87,7 +87,7 @@ crate struct IndexItem { crate name: String, crate path: String, crate desc: String, - crate parent: Option<DefId>, + crate parent: Option<FakeDefId>, 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<DefId>, + ty: Option<FakeDefId>, 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<DefId>, + defid: Option<FakeDefId>, idx: Option<usize>, } @@ -709,7 +709,7 @@ fn render_impls( .map(|i| { let did = i.trait_did_full(cache).unwrap(); let provided_trait_methods = i.inner_impl().provided_trait_methods(tcx); - let assoc_link = AssocItemLink::GotoSource(did, &provided_trait_methods); + let assoc_link = AssocItemLink::GotoSource(did.into(), &provided_trait_methods); let mut buffer = if w.is_for_html() { Buffer::html() } else { Buffer::new() }; render_impl( &mut buffer, @@ -747,7 +747,7 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink<'_>, cx: &Context<'_>) AssocItemLink::Anchor(Some(ref id)) => format!("#{}", id), AssocItemLink::Anchor(None) => anchor, AssocItemLink::GotoSource(did, _) => { - href(did, cx).map(|p| format!("{}{}", p.0, anchor)).unwrap_or(anchor) + href(did.expect_real(), cx).map(|p| format!("{}{}", p.0, anchor)).unwrap_or(anchor) } } } @@ -855,7 +855,7 @@ fn render_assoc_item( ItemType::TyMethod }; - href(did, cx) + href(did.expect_real(), cx) .map(|p| format!("{}#{}.{}", p.0, ty, name)) .unwrap_or_else(|| format!("#{}.{}", ty, name)) } @@ -979,7 +979,7 @@ fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item) { #[derive(Copy, Clone)] enum AssocItemLink<'a> { Anchor(Option<&'a str>), - GotoSource(DefId, &'a FxHashSet<Symbol>), + GotoSource(FakeDefId, &'a FxHashSet<Symbol>), } impl<'a> AssocItemLink<'a> { @@ -1217,7 +1217,7 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String { it, &[], Some(&tydef.type_), - AssocItemLink::GotoSource(t_did, &FxHashSet::default()), + AssocItemLink::GotoSource(t_did.into(), &FxHashSet::default()), "", cx, ); @@ -1476,7 +1476,7 @@ fn render_impl( } let did = i.trait_.as_ref().unwrap().def_id_full(cx.cache()).unwrap(); let provided_methods = i.provided_trait_methods(cx.tcx()); - let assoc_link = AssocItemLink::GotoSource(did, &provided_methods); + let assoc_link = AssocItemLink::GotoSource(did.into(), &provided_methods); doc_impl_item( boring, @@ -1810,7 +1810,8 @@ fn small_url_encode(s: String) -> String { } fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) { - if let Some(v) = cx.cache.impls.get(&it.def_id) { + let did = it.def_id.expect_real(); + if let Some(v) = cx.cache.impls.get(&did) { let mut used_links = FxHashSet::default(); let cache = cx.cache(); |
