rustdoc: Rename internal uses of spotlight
I didn't make these renames in #80965 because I didn't want the PR to conflict with #80914.
This commit is contained in:
parent
36bcf40697
commit
5f96c48de2
6 changed files with 20 additions and 19 deletions
|
@ -624,7 +624,7 @@ crate fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
|
||||||
|
|
||||||
let trait_ = clean::TraitWithExtraInfo {
|
let trait_ = clean::TraitWithExtraInfo {
|
||||||
trait_,
|
trait_,
|
||||||
is_spotlight: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
|
is_notable: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
|
||||||
};
|
};
|
||||||
cx.external_traits.borrow_mut().insert(did, trait_);
|
cx.external_traits.borrow_mut().insert(did, trait_);
|
||||||
cx.active_extern_traits.remove(&did);
|
cx.active_extern_traits.remove(&did);
|
||||||
|
|
|
@ -65,7 +65,7 @@ crate struct Crate {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
crate struct TraitWithExtraInfo {
|
crate struct TraitWithExtraInfo {
|
||||||
crate trait_: Trait,
|
crate trait_: Trait,
|
||||||
crate is_spotlight: bool,
|
crate is_notable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
@ -464,10 +464,9 @@ crate fn run_global_ctxt(
|
||||||
if let Some(sized_trait_did) = ctxt.tcx.lang_items().sized_trait() {
|
if let Some(sized_trait_did) = ctxt.tcx.lang_items().sized_trait() {
|
||||||
let mut sized_trait = build_external_trait(&mut ctxt, sized_trait_did);
|
let mut sized_trait = build_external_trait(&mut ctxt, sized_trait_did);
|
||||||
sized_trait.is_auto = true;
|
sized_trait.is_auto = true;
|
||||||
ctxt.external_traits.borrow_mut().insert(
|
ctxt.external_traits
|
||||||
sized_trait_did,
|
.borrow_mut()
|
||||||
TraitWithExtraInfo { trait_: sized_trait, is_spotlight: false },
|
.insert(sized_trait_did, TraitWithExtraInfo { trait_: sized_trait, is_notable: false });
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("crate: {:?}", tcx.hir().krate());
|
debug!("crate: {:?}", tcx.hir().krate());
|
||||||
|
|
|
@ -116,7 +116,7 @@ crate struct Cache {
|
||||||
// even though the trait itself is not exported. This can happen if a trait
|
// even though the trait itself is not exported. This can happen if a trait
|
||||||
// was defined in function/expression scope, since the impl will be picked
|
// was defined in function/expression scope, since the impl will be picked
|
||||||
// up by `collect-trait-impls` but the trait won't be scraped out in the HIR
|
// up by `collect-trait-impls` but the trait won't be scraped out in the HIR
|
||||||
// crawl. In order to prevent crashes when looking for spotlight traits or
|
// crawl. In order to prevent crashes when looking for notable traits or
|
||||||
// when gathering trait documentation on a type, hold impls here while
|
// when gathering trait documentation on a type, hold impls here while
|
||||||
// folding and add them to the cache later on if we find the trait.
|
// folding and add them to the cache later on if we find the trait.
|
||||||
orphan_trait_impls: Vec<(DefId, FxHashSet<DefId>, Impl)>,
|
orphan_trait_impls: Vec<(DefId, FxHashSet<DefId>, Impl)>,
|
||||||
|
@ -227,7 +227,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||||
if let clean::TraitItem(ref t) = *item.kind {
|
if let clean::TraitItem(ref t) = *item.kind {
|
||||||
self.cache.traits.entry(item.def_id).or_insert_with(|| clean::TraitWithExtraInfo {
|
self.cache.traits.entry(item.def_id).or_insert_with(|| clean::TraitWithExtraInfo {
|
||||||
trait_: t.clone(),
|
trait_: t.clone(),
|
||||||
is_spotlight: item.attrs.has_doc_flag(sym::notable_trait),
|
is_notable: item.attrs.has_doc_flag(sym::notable_trait),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ fn render_assoc_item(
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"{}{}{}{}{}{}{}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
|
"{}{}{}{}{}{}{}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
|
||||||
{generics}{decl}{spotlight}{where_clause}",
|
{generics}{decl}{notable_traits}{where_clause}",
|
||||||
if parent == ItemType::Trait { " " } else { "" },
|
if parent == ItemType::Trait { " " } else { "" },
|
||||||
vis,
|
vis,
|
||||||
constness,
|
constness,
|
||||||
|
@ -1057,7 +1057,7 @@ fn render_assoc_item(
|
||||||
name = name,
|
name = name,
|
||||||
generics = g.print(cache, tcx),
|
generics = g.print(cache, tcx),
|
||||||
decl = d.full_print(cache, tcx, header_len, indent, header.asyncness),
|
decl = d.full_print(cache, tcx, header_len, indent, header.asyncness),
|
||||||
spotlight = spotlight_decl(&d, cache, tcx),
|
notable_traits = notable_traits_decl(&d, cache, tcx),
|
||||||
where_clause = print_where_clause(g, cache, tcx, indent, end_newline),
|
where_clause = print_where_clause(g, cache, tcx, indent, end_newline),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1341,7 +1341,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, cache: &Cache) -> bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spotlight_decl(decl: &clean::FnDecl, cache: &Cache, tcx: TyCtxt<'_>) -> String {
|
fn notable_traits_decl(decl: &clean::FnDecl, cache: &Cache, tcx: TyCtxt<'_>) -> String {
|
||||||
let mut out = Buffer::html();
|
let mut out = Buffer::html();
|
||||||
let mut trait_ = String::new();
|
let mut trait_ = String::new();
|
||||||
|
|
||||||
|
@ -1349,9 +1349,11 @@ fn spotlight_decl(decl: &clean::FnDecl, cache: &Cache, tcx: TyCtxt<'_>) -> Strin
|
||||||
if let Some(impls) = cache.impls.get(&did) {
|
if let Some(impls) = cache.impls.get(&did) {
|
||||||
for i in impls {
|
for i in impls {
|
||||||
let impl_ = i.inner_impl();
|
let impl_ = i.inner_impl();
|
||||||
if impl_.trait_.def_id().map_or(false, |d| {
|
if impl_
|
||||||
cache.traits.get(&d).map(|t| t.is_spotlight).unwrap_or(false)
|
.trait_
|
||||||
}) {
|
.def_id()
|
||||||
|
.map_or(false, |d| cache.traits.get(&d).map(|t| t.is_notable).unwrap_or(false))
|
||||||
|
{
|
||||||
if out.is_empty() {
|
if out.is_empty() {
|
||||||
write!(
|
write!(
|
||||||
&mut out,
|
&mut out,
|
||||||
|
|
|
@ -10,9 +10,9 @@ use rustc_span::hygiene::MacroKind;
|
||||||
use rustc_span::symbol::{kw, sym, Symbol};
|
use rustc_span::symbol::{kw, sym, Symbol};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, render_assoc_item,
|
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
|
||||||
render_assoc_items, render_attributes, render_impl, render_stability_since_raw, spotlight_decl,
|
render_assoc_item, render_assoc_items, render_attributes, render_impl,
|
||||||
write_srclink, AssocItemLink, Context,
|
render_stability_since_raw, write_srclink, AssocItemLink, Context,
|
||||||
};
|
};
|
||||||
use crate::clean::{self, GetDefId};
|
use crate::clean::{self, GetDefId};
|
||||||
use crate::formats::cache::Cache;
|
use crate::formats::cache::Cache;
|
||||||
|
@ -381,7 +381,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
|
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
|
||||||
{name}{generics}{decl}{spotlight}{where_clause}</pre>",
|
{name}{generics}{decl}{notable_traits}{where_clause}</pre>",
|
||||||
vis = it.visibility.print_with_space(cx.tcx(), it.def_id, cx.cache()),
|
vis = it.visibility.print_with_space(cx.tcx(), it.def_id, cx.cache()),
|
||||||
constness = f.header.constness.print_with_space(),
|
constness = f.header.constness.print_with_space(),
|
||||||
asyncness = f.header.asyncness.print_with_space(),
|
asyncness = f.header.asyncness.print_with_space(),
|
||||||
|
@ -391,7 +391,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
|
||||||
generics = f.generics.print(cx.cache(), cx.tcx()),
|
generics = f.generics.print(cx.cache(), cx.tcx()),
|
||||||
where_clause = print_where_clause(&f.generics, cx.cache(), cx.tcx(), 0, true),
|
where_clause = print_where_clause(&f.generics, cx.cache(), cx.tcx(), 0, true),
|
||||||
decl = f.decl.full_print(cx.cache(), cx.tcx(), header_len, 0, f.header.asyncness),
|
decl = f.decl.full_print(cx.cache(), cx.tcx(), header_len, 0, f.header.asyncness),
|
||||||
spotlight = spotlight_decl(&f.decl, cx.cache(), cx.tcx()),
|
notable_traits = notable_traits_decl(&f.decl, cx.cache(), cx.tcx()),
|
||||||
);
|
);
|
||||||
document(w, cx, it, None)
|
document(w, cx, it, None)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue