Skip to content

Commit 0daec04

Browse files
authored
Rollup merge of rust-lang#83756 - camelid:internal-rename-doc-spotlight, r=GuillaumeGomez
rustdoc: Rename internal uses of `spotlight` I didn't make these renames in rust-lang#80965 because I didn't want the PR to conflict with rust-lang#80914.
2 parents 3b40d2c + 1fe0fe4 commit 0daec04

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ crate fn record_extern_trait(cx: &mut DocContext<'_>, did: DefId) {
624624

625625
let trait_ = clean::TraitWithExtraInfo {
626626
trait_,
627-
is_spotlight: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
627+
is_notable: clean::utils::has_doc_flag(cx.tcx.get_attrs(did), sym::notable_trait),
628628
};
629629
cx.external_traits.borrow_mut().insert(did, trait_);
630630
cx.active_extern_traits.remove(&did);

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ crate struct Crate {
6565
#[derive(Clone, Debug)]
6666
crate struct TraitWithExtraInfo {
6767
crate trait_: Trait,
68-
crate is_spotlight: bool,
68+
crate is_notable: bool,
6969
}
7070

7171
#[derive(Clone, Debug)]

src/librustdoc/core.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,9 @@ crate fn run_global_ctxt(
488488
if let Some(sized_trait_did) = ctxt.tcx.lang_items().sized_trait() {
489489
let mut sized_trait = build_external_trait(&mut ctxt, sized_trait_did);
490490
sized_trait.is_auto = true;
491-
ctxt.external_traits.borrow_mut().insert(
492-
sized_trait_did,
493-
TraitWithExtraInfo { trait_: sized_trait, is_spotlight: false },
494-
);
491+
ctxt.external_traits
492+
.borrow_mut()
493+
.insert(sized_trait_did, TraitWithExtraInfo { trait_: sized_trait, is_notable: false });
495494
}
496495

497496
debug!("crate: {:?}", tcx.hir().krate());

src/librustdoc/formats/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ crate struct Cache {
116116
// even though the trait itself is not exported. This can happen if a trait
117117
// was defined in function/expression scope, since the impl will be picked
118118
// up by `collect-trait-impls` but the trait won't be scraped out in the HIR
119-
// crawl. In order to prevent crashes when looking for spotlight traits or
119+
// crawl. In order to prevent crashes when looking for notable traits or
120120
// when gathering trait documentation on a type, hold impls here while
121121
// folding and add them to the cache later on if we find the trait.
122122
orphan_trait_impls: Vec<(DefId, FxHashSet<DefId>, Impl)>,
@@ -227,7 +227,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
227227
if let clean::TraitItem(ref t) = *item.kind {
228228
self.cache.traits.entry(item.def_id).or_insert_with(|| clean::TraitWithExtraInfo {
229229
trait_: t.clone(),
230-
is_spotlight: item.attrs.has_doc_flag(sym::notable_trait),
230+
is_notable: item.attrs.has_doc_flag(sym::notable_trait),
231231
});
232232
}
233233

src/librustdoc/html/render/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ fn render_assoc_item(
10451045
write!(
10461046
w,
10471047
"{}{}{}{}{}{}{}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
1048-
{generics}{decl}{spotlight}{where_clause}",
1048+
{generics}{decl}{notable_traits}{where_clause}",
10491049
if parent == ItemType::Trait { " " } else { "" },
10501050
vis,
10511051
constness,
@@ -1057,7 +1057,7 @@ fn render_assoc_item(
10571057
name = name,
10581058
generics = g.print(cache, tcx),
10591059
decl = d.full_print(cache, tcx, header_len, indent, header.asyncness),
1060-
spotlight = spotlight_decl(&d, cache, tcx),
1060+
notable_traits = notable_traits_decl(&d, cache, tcx),
10611061
where_clause = print_where_clause(g, cache, tcx, indent, end_newline),
10621062
)
10631063
}
@@ -1341,17 +1341,19 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, cache: &Cache) -> bo
13411341
}
13421342
}
13431343

1344-
fn spotlight_decl(decl: &clean::FnDecl, cache: &Cache, tcx: TyCtxt<'_>) -> String {
1344+
fn notable_traits_decl(decl: &clean::FnDecl, cache: &Cache, tcx: TyCtxt<'_>) -> String {
13451345
let mut out = Buffer::html();
13461346
let mut trait_ = String::new();
13471347

13481348
if let Some(did) = decl.output.def_id_full(cache) {
13491349
if let Some(impls) = cache.impls.get(&did) {
13501350
for i in impls {
13511351
let impl_ = i.inner_impl();
1352-
if impl_.trait_.def_id().map_or(false, |d| {
1353-
cache.traits.get(&d).map(|t| t.is_spotlight).unwrap_or(false)
1354-
}) {
1352+
if impl_
1353+
.trait_
1354+
.def_id()
1355+
.map_or(false, |d| cache.traits.get(&d).map(|t| t.is_notable).unwrap_or(false))
1356+
{
13551357
if out.is_empty() {
13561358
write!(
13571359
&mut out,

src/librustdoc/html/render/print_item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_span::hygiene::MacroKind;
1010
use rustc_span::symbol::{kw, sym, Symbol};
1111

1212
use super::{
13-
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, render_assoc_item,
14-
render_assoc_items, render_attributes, render_impl, render_stability_since_raw, spotlight_decl,
15-
write_srclink, AssocItemLink, Context,
13+
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
14+
render_assoc_item, render_assoc_items, render_attributes, render_impl,
15+
render_stability_since_raw, write_srclink, AssocItemLink, Context,
1616
};
1717
use crate::clean::{self, GetDefId};
1818
use crate::formats::cache::Cache;
@@ -381,7 +381,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
381381
write!(
382382
w,
383383
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
384-
{name}{generics}{decl}{spotlight}{where_clause}</pre>",
384+
{name}{generics}{decl}{notable_traits}{where_clause}</pre>",
385385
vis = it.visibility.print_with_space(cx.tcx(), it.def_id, cx.cache()),
386386
constness = f.header.constness.print_with_space(),
387387
asyncness = f.header.asyncness.print_with_space(),
@@ -391,7 +391,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
391391
generics = f.generics.print(cx.cache(), cx.tcx()),
392392
where_clause = print_where_clause(&f.generics, cx.cache(), cx.tcx(), 0, true),
393393
decl = f.decl.full_print(cx.cache(), cx.tcx(), header_len, 0, f.header.asyncness),
394-
spotlight = spotlight_decl(&f.decl, cx.cache(), cx.tcx()),
394+
notable_traits = notable_traits_decl(&f.decl, cx.cache(), cx.tcx()),
395395
);
396396
document(w, cx, it, None)
397397
}

src/librustdoc/html/static/rustdoc.css

+1-4
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,10 @@ code, pre, a.test-arrow {
173173
border-radius: 3px;
174174
padding: 0 0.1em;
175175
}
176-
.docblock pre code, .docblock-short pre code, .docblock code.spotlight {
176+
.docblock pre code, .docblock-short pre code {
177177
padding: 0;
178178
padding-right: 1ex;
179179
}
180-
.docblock code.spotlight :last-child {
181-
padding-bottom: 0.6em;
182-
}
183180
pre {
184181
padding: 14px;
185182
}

0 commit comments

Comments
 (0)