Skip to content

Commit 9a64180

Browse files
Unify cache usage and improve naming
1 parent 522f48c commit 9a64180

File tree

1 file changed

+12
-11
lines changed
  • src/librustdoc/html/render

1 file changed

+12
-11
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ themePicker.onblur = handleThemeButtonsBlur;
11441144
Some(Implementor {
11451145
text: imp.inner_impl().print(cx.cache()).to_string(),
11461146
synthetic: imp.inner_impl().synthetic,
1147-
types: collect_paths_for_type(imp.inner_impl().for_.clone(), &cx.cache),
1147+
types: collect_paths_for_type(imp.inner_impl().for_.clone(), cx.cache()),
11481148
})
11491149
}
11501150
})
@@ -2466,7 +2466,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
24662466
WhereClause { gens: &f.generics, indent: 0, end_newline: true }.print(cx.cache()),
24672467
decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness }
24682468
.print(cx.cache()),
2469-
spotlight = spotlight_decl(&f.decl, &cx.cache),
2469+
spotlight = spotlight_decl(&f.decl, cx.cache()),
24702470
);
24712471
document(w, cx, it, None)
24722472
}
@@ -3685,30 +3685,31 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, cache: &Cache) -> bo
36853685
}
36863686
}
36873687

3688-
fn spotlight_decl(decl: &clean::FnDecl, c: &Cache) -> String {
3688+
fn spotlight_decl(decl: &clean::FnDecl, cache: &Cache) -> String {
36893689
let mut out = Buffer::html();
36903690
let mut trait_ = String::new();
36913691

3692-
if let Some(did) = decl.output.def_id_full(c) {
3693-
if let Some(impls) = c.impls.get(&did) {
3692+
if let Some(did) = decl.output.def_id_full(cache) {
3693+
if let Some(impls) = cache.impls.get(&did) {
36943694
for i in impls {
36953695
let impl_ = i.inner_impl();
3696-
if impl_.trait_.def_id_full(c).map_or(false, |d| c.traits[&d].is_spotlight) {
3696+
if impl_.trait_.def_id_full(cache).map_or(false, |d| cache.traits[&d].is_spotlight)
3697+
{
36973698
if out.is_empty() {
36983699
out.push_str(&format!(
36993700
"<h3 class=\"notable\">Notable traits for {}</h3>\
37003701
<code class=\"content\">",
3701-
impl_.for_.print(c)
3702+
impl_.for_.print(cache)
37023703
));
3703-
trait_.push_str(&impl_.for_.print(c).to_string());
3704+
trait_.push_str(&impl_.for_.print(cache).to_string());
37043705
}
37053706

37063707
//use the "where" class here to make it small
37073708
out.push_str(&format!(
37083709
"<span class=\"where fmt-newline\">{}</span>",
3709-
impl_.print(c)
3710+
impl_.print(cache)
37103711
));
3711-
let t_did = impl_.trait_.def_id_full(c).unwrap();
3712+
let t_did = impl_.trait_.def_id_full(cache).unwrap();
37123713
for it in &impl_.items {
37133714
if let clean::TypedefItem(ref tydef, _) = *it.kind {
37143715
out.push_str("<span class=\"where fmt-newline\"> ");
@@ -3719,7 +3720,7 @@ fn spotlight_decl(decl: &clean::FnDecl, c: &Cache) -> String {
37193720
Some(&tydef.type_),
37203721
AssocItemLink::GotoSource(t_did, &FxHashSet::default()),
37213722
"",
3722-
c,
3723+
cache,
37233724
);
37243725
out.push_str(";</span>");
37253726
}

0 commit comments

Comments
 (0)