\
@@ -722,7 +713,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
}
fn cache(&self) -> &Cache {
- &self.cache
+ &self.shared.cache
}
}
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index fd2e18a8be77f..7704abc9a72c8 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -1012,11 +1012,11 @@ fn render_assoc_items(
what: AssocItemRender<'_>,
) {
info!("Documenting associated items of {:?}", containing_item.name);
- let v = match cx.cache.impls.get(&it) {
+ let cache = cx.cache();
+ let v = match cache.impls.get(&it) {
Some(v) => v,
None => return,
};
- let cache = cx.cache();
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
if !non_trait.is_empty() {
let render_mode = match what {
@@ -1063,11 +1063,11 @@ fn render_assoc_items(
if !traits.is_empty() {
let deref_impl = traits
.iter()
- .find(|t| t.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_trait_did);
+ .find(|t| t.inner_impl().trait_.def_id_full(cache) == cache.deref_trait_did);
if let Some(impl_) = deref_impl {
let has_deref_mut = traits
.iter()
- .any(|t| t.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_mut_trait_did);
+ .any(|t| t.inner_impl().trait_.def_id_full(cache) == cache.deref_mut_trait_did);
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut);
}
let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) =
@@ -1122,6 +1122,7 @@ fn render_deref_methods(
container_item: &clean::Item,
deref_mut: bool,
) {
+ let cache = cx.cache();
let deref_type = impl_.inner_impl().trait_.as_ref().unwrap();
let (target, real_target) = impl_
.inner_impl()
@@ -1138,8 +1139,8 @@ fn render_deref_methods(
debug!("Render deref methods for {:#?}, target {:#?}", impl_.inner_impl().for_, target);
let what =
AssocItemRender::DerefFor { trait_: deref_type, type_: real_target, deref_mut_: deref_mut };
- if let Some(did) = target.def_id_full(cx.cache()) {
- if let Some(type_did) = impl_.inner_impl().for_.def_id_full(cx.cache()) {
+ if let Some(did) = target.def_id_full(cache) {
+ if let Some(type_did) = impl_.inner_impl().for_.def_id_full(cache) {
// `impl Deref
for S`
if did == type_did {
// Avoid infinite cycles
@@ -1149,7 +1150,7 @@ fn render_deref_methods(
render_assoc_items(w, cx, container_item, did, what);
} else {
if let Some(prim) = target.primitive_type() {
- if let Some(&did) = cx.cache.primitive_locations.get(&prim) {
+ if let Some(&did) = cache.primitive_locations.get(&prim) {
render_assoc_items(w, cx, container_item, did, what);
}
}
@@ -1286,7 +1287,7 @@ fn render_impl(
let render_method_item = match render_mode {
RenderMode::Normal => true,
RenderMode::ForDeref { mut_: deref_mut_ } => {
- should_render_item(&item, deref_mut_, &cx.cache)
+ should_render_item(&item, deref_mut_, cx.cache())
}
};
@@ -1678,7 +1679,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
}
if it.is_crate() {
- if let Some(ref version) = cx.cache.crate_version {
+ if let Some(ref version) = cx.cache().crate_version {
write!(
buffer,
"\
@@ -1825,18 +1826,16 @@ fn small_url_encode(s: String) -> String {
fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
let did = it.def_id.expect_def_id();
- if let Some(v) = cx.cache.impls.get(&did) {
+ let cache = cx.cache();
+ if let Some(v) = cache.impls.get(&did) {
let mut used_links = FxHashSet::default();
- let cache = cx.cache();
{
let used_links_bor = &mut used_links;
let mut ret = v
.iter()
.filter(|i| i.inner_impl().trait_.is_none())
- .flat_map(move |i| {
- get_methods(i.inner_impl(), false, used_links_bor, false, &cx.cache)
- })
+ .flat_map(move |i| get_methods(i.inner_impl(), false, used_links_bor, false, cache))
.collect::>();
if !ret.is_empty() {
// We want links' order to be reproducible so we don't use unstable sort.
@@ -1857,7 +1856,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
if let Some(impl_) = v
.iter()
.filter(|i| i.inner_impl().trait_.is_some())
- .find(|i| i.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_trait_did)
+ .find(|i| i.inner_impl().trait_.def_id_full(cache) == cache.deref_trait_did)
{
sidebar_deref_methods(cx, out, impl_, v);
}
@@ -2117,15 +2116,15 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean
"
",
);
- if let Some(implementors) = cx.cache.implementors.get(&it.def_id.expect_def_id()) {
- let cache = cx.cache();
+ let cache = cx.cache();
+ if let Some(implementors) = cache.implementors.get(&it.def_id.expect_def_id()) {
let mut res = implementors
.iter()
.filter(|i| {
i.inner_impl()
.for_
.def_id_full(cache)
- .map_or(false, |d| !cx.cache.paths.contains_key(&d))
+ .map_or(false, |d| !cache.paths.contains_key(&d))
})
.filter_map(|i| extract_for_impl_name(&i.impl_item, cx))
.collect::>();
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 96cc67ce97c75..8f4857a693928 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -690,7 +690,8 @@ 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_def_id(), AssocItemRender::All);
- if let Some(implementors) = cx.cache.implementors.get(&it.def_id.expect_def_id()) {
+ let cache = cx.cache();
+ if let Some(implementors) = cache.implementors.get(&it.def_id.expect_def_id()) {
// 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 = FxHashMap::default();
@@ -712,10 +713,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
}
let (local, foreign) = implementors.iter().partition::, _>(|i| {
- i.inner_impl()
- .for_
- .def_id_full(cx.cache())
- .map_or(true, |d| cx.cache.paths.contains_key(&d))
+ i.inner_impl().for_.def_id_full(cache).map_or(true, |d| cache.paths.contains_key(&d))
});
let (mut synthetic, mut concrete): (Vec<&&Impl>, Vec<&&Impl>) =
@@ -772,7 +770,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
it,
w,
&implementor_dups,
- &collect_paths_for_type(implementor.inner_impl().for_.clone(), &cx.cache),
+ &collect_paths_for_type(implementor.inner_impl().for_.clone(), cache),
);
}
w.write_str(" ");
@@ -806,7 +804,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
path = if it.def_id.is_local() {
cx.current.join("/")
} else {
- let (ref path, _) = cx.cache.external_paths[&it.def_id.expect_def_id()];
+ let (ref path, _) = cache.external_paths[&it.def_id.expect_def_id()];
path[..path.len() - 1].join("/")
},
ty = it.type_(),
diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs
index c16769c474a21..99cd98f7eaeb8 100644
--- a/src/librustdoc/html/render/write_shared.rs
+++ b/src/librustdoc/html/render/write_shared.rs
@@ -518,7 +518,8 @@ 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 cache = cx.cache();
+ for (&did, imps) in &cache.implementors {
// 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
@@ -526,9 +527,9 @@ pub(super) fn write_shared(
//
// FIXME: this is a vague explanation for why this can't be a `get`, in
// theory it should be...
- let &(ref remote_path, remote_item_type) = match cx.cache.paths.get(&did) {
+ let &(ref remote_path, remote_item_type) = match cache.paths.get(&did) {
Some(p) => p,
- None => match cx.cache.external_paths.get(&did) {
+ None => match cache.external_paths.get(&did) {
Some(p) => p,
None => continue,
},
@@ -557,7 +558,7 @@ pub(super) fn write_shared(
Some(Implementor {
text: imp.inner_impl().print(false, cx).to_string(),
synthetic: imp.inner_impl().synthetic,
- types: collect_paths_for_type(imp.inner_impl().for_.clone(), cx.cache()),
+ types: collect_paths_for_type(imp.inner_impl().for_.clone(), cache),
})
}
})
@@ -566,7 +567,7 @@ pub(super) fn write_shared(
// Only create a js file if we have impls to add to it. If the trait is
// documented locally though we always create the file to avoid dead
// links.
- if implementors.is_empty() && !cx.cache.paths.contains_key(&did) {
+ if implementors.is_empty() && !cache.paths.contains_key(&did) {
continue;
}