Skip to content

Commit 6115035

Browse files
authored
Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnison
Remove spotlight I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it. r? @kinnison cc @ollie27
2 parents 5b08aad + 13c6d58 commit 6115035

File tree

22 files changed

+7
-400
lines changed

22 files changed

+7
-400
lines changed

src/doc/rustdoc/src/unstable-features.md

-21
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,6 @@ Book][unstable-doc-cfg] and [its tracking issue][issue-doc-cfg].
138138
[unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html
139139
[issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781
140140

141-
### Adding your trait to the "Important Traits" dialog
142-
143-
Rustdoc keeps a list of a few traits that are believed to be "fundamental" to a given type when
144-
implemented on it. These traits are intended to be the primary interface for their types, and are
145-
often the only thing available to be documented on their types. For this reason, Rustdoc will track
146-
when a given type implements one of these traits and call special attention to it when a function
147-
returns one of these types. This is the "Important Traits" dialog, visible as a circle-i button next
148-
to the function, which, when clicked, shows the dialog.
149-
150-
In the standard library, the traits that qualify for inclusion are `Iterator`, `io::Read`, and
151-
`io::Write`. However, rather than being implemented as a hard-coded list, these traits have a
152-
special marker attribute on them: `#[doc(spotlight)]`. This means that you could apply this
153-
attribute to your own trait to include it in the "Important Traits" dialog in documentation.
154-
155-
The `#[doc(spotlight)]` attribute currently requires the `#![feature(doc_spotlight)]` feature gate.
156-
For more information, see [its chapter in the Unstable Book][unstable-spotlight] and [its tracking
157-
issue][issue-spotlight].
158-
159-
[unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html
160-
[issue-spotlight]: https://github.com/rust-lang/rust/issues/45040
161-
162141
### Exclude certain dependencies from documentation
163142

164143
The standard library uses several dependencies which, in turn, use several types and traits from the

src/doc/unstable-book/src/language-features/doc-spotlight.md

-30
This file was deleted.

src/libcore/future/future.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::task::{Context, Poll};
2424
/// `.await` the value.
2525
///
2626
/// [`Waker`]: ../task/struct.Waker.html
27-
#[doc(spotlight)]
2827
#[must_use = "futures do nothing unless you `.await` or poll them"]
2928
#[stable(feature = "futures_api", since = "1.36.0")]
3029
#[lang = "future_trait"]

src/libcore/iter/traits/iterator.rs

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
9292
label = "`{Self}` is not an iterator",
9393
message = "`{Self}` is not an iterator"
9494
)]
95-
#[doc(spotlight)]
9695
#[must_use = "iterators are lazy and do nothing unless consumed"]
9796
pub trait Iterator {
9897
/// The type of the elements being iterated over.

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
#![feature(custom_inner_attributes)]
9191
#![feature(decl_macro)]
9292
#![feature(doc_cfg)]
93-
#![feature(doc_spotlight)]
9493
#![feature(extern_types)]
9594
#![feature(fundamental)]
9695
#![feature(intrinsics)]

src/librustc_ast_passes/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
245245
include => external_doc
246246
cfg => doc_cfg
247247
masked => doc_masked
248-
spotlight => doc_spotlight
249248
alias => doc_alias
250249
keyword => doc_keyword
251250
);

src/librustc_feature/active.rs

-3
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ declare_features! (
360360
/// Allows `#[doc(masked)]`.
361361
(active, doc_masked, "1.21.0", Some(44027), None),
362362

363-
/// Allows `#[doc(spotlight)]`.
364-
(active, doc_spotlight, "1.22.0", Some(45040), None),
365-
366363
/// Allows `#[doc(include = "some-file")]`.
367364
(active, external_doc, "1.22.0", Some(44732), None),
368365

src/librustc_span/symbol.rs

-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ symbols! {
270270
doc_cfg,
271271
doc_keyword,
272272
doc_masked,
273-
doc_spotlight,
274273
doctest,
275274
document_private_items,
276275
dotdoteq_in_patterns,
@@ -689,7 +688,6 @@ symbols! {
689688
Some,
690689
specialization,
691690
speed,
692-
spotlight,
693691
sse4a_target_feature,
694692
stable,
695693
staged_api,

src/librustdoc/clean/inline.rs

-2
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,13 @@ pub fn build_external_trait(cx: &DocContext<'_>, did: DefId) -> clean::Trait {
198198
let generics = (cx.tcx.generics_of(did), predicates).clean(cx);
199199
let generics = filter_non_trait_generics(did, generics);
200200
let (generics, supertrait_bounds) = separate_supertrait_bounds(generics);
201-
let is_spotlight = load_attrs(cx, did).clean(cx).has_doc_flag(sym::spotlight);
202201
let is_auto = cx.tcx.trait_is_auto(did);
203202
clean::Trait {
204203
auto: auto_trait,
205204
unsafety: cx.tcx.trait_def(did).unsafety,
206205
generics,
207206
items: trait_items,
208207
bounds: supertrait_bounds,
209-
is_spotlight,
210208
is_auto,
211209
}
212210
}

src/librustdoc/clean/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,6 @@ impl Clean<FnRetTy> for hir::FnRetTy<'_> {
10131013
impl Clean<Item> for doctree::Trait<'_> {
10141014
fn clean(&self, cx: &DocContext<'_>) -> Item {
10151015
let attrs = self.attrs.clean(cx);
1016-
let is_spotlight = attrs.has_doc_flag(sym::spotlight);
10171016
Item {
10181017
name: Some(self.name.clean(cx)),
10191018
attrs,
@@ -1028,7 +1027,6 @@ impl Clean<Item> for doctree::Trait<'_> {
10281027
items: self.items.iter().map(|ti| ti.clean(cx)).collect(),
10291028
generics: self.generics.clean(cx),
10301029
bounds: self.bounds.clean(cx),
1031-
is_spotlight,
10321030
is_auto: self.is_auto.clean(cx),
10331031
}),
10341032
}

src/librustdoc/clean/types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,6 @@ pub struct Trait {
951951
pub items: Vec<Item>,
952952
pub generics: Generics,
953953
pub bounds: Vec<GenericBound>,
954-
pub is_spotlight: bool,
955954
pub is_auto: bool,
956955
}
957956

src/librustdoc/html/format.rs

-12
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,10 @@ impl Buffer {
6363
Buffer { for_html: false, buffer: String::new() }
6464
}
6565

66-
crate fn is_empty(&self) -> bool {
67-
self.buffer.is_empty()
68-
}
69-
7066
crate fn into_inner(self) -> String {
7167
self.buffer
7268
}
7369

74-
crate fn insert_str(&mut self, idx: usize, s: &str) {
75-
self.buffer.insert_str(idx, s);
76-
}
77-
78-
crate fn push_str(&mut self, s: &str) {
79-
self.buffer.push_str(s);
80-
}
81-
8270
// Intended for consumption by write! and writeln! (std::fmt) but without
8371
// the fmt::Result return type imposed by fmt::Write (and avoiding the trait
8472
// import).

src/librustdoc/html/render.rs

+4-81
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,7 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23252325
f.generics.print()
23262326
)
23272327
.len();
2328-
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it));
2328+
write!(w, "<pre class='rust fn'>");
23292329
render_attributes(w, it, false);
23302330
write!(
23312331
w,
@@ -2528,13 +2528,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
25282528
let item_type = m.type_();
25292529
let id = cx.derive_id(format!("{}.{}", item_type, name));
25302530
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
2531-
write!(
2532-
w,
2533-
"<h3 id='{id}' class='method'>{extra}<code id='{ns_id}'>",
2534-
extra = render_spotlight_traits(m),
2535-
id = id,
2536-
ns_id = ns_id
2537-
);
2531+
write!(w, "<h3 id='{id}' class='method'><code id='{ns_id}'>", id = id, ns_id = ns_id);
25382532
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
25392533
write!(w, "</code>");
25402534
render_stability_since(w, m, t);
@@ -3520,76 +3514,6 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
35203514
}
35213515
}
35223516

3523-
fn render_spotlight_traits(item: &clean::Item) -> String {
3524-
match item.inner {
3525-
clean::FunctionItem(clean::Function { ref decl, .. })
3526-
| clean::TyMethodItem(clean::TyMethod { ref decl, .. })
3527-
| clean::MethodItem(clean::Method { ref decl, .. })
3528-
| clean::ForeignFunctionItem(clean::Function { ref decl, .. }) => spotlight_decl(decl),
3529-
_ => String::new(),
3530-
}
3531-
}
3532-
3533-
fn spotlight_decl(decl: &clean::FnDecl) -> String {
3534-
let mut out = Buffer::html();
3535-
let mut trait_ = String::new();
3536-
3537-
if let Some(did) = decl.output.def_id() {
3538-
let c = cache();
3539-
if let Some(impls) = c.impls.get(&did) {
3540-
for i in impls {
3541-
let impl_ = i.inner_impl();
3542-
if impl_.trait_.def_id().map_or(false, |d| c.traits[&d].is_spotlight) {
3543-
if out.is_empty() {
3544-
out.push_str(&format!(
3545-
"<h3 class=\"important\">Important traits for {}</h3>\
3546-
<code class=\"content\">",
3547-
impl_.for_.print()
3548-
));
3549-
trait_.push_str(&impl_.for_.print().to_string());
3550-
}
3551-
3552-
//use the "where" class here to make it small
3553-
out.push_str(&format!(
3554-
"<span class=\"where fmt-newline\">{}</span>",
3555-
impl_.print()
3556-
));
3557-
let t_did = impl_.trait_.def_id().unwrap();
3558-
for it in &impl_.items {
3559-
if let clean::TypedefItem(ref tydef, _) = it.inner {
3560-
out.push_str("<span class=\"where fmt-newline\"> ");
3561-
assoc_type(
3562-
&mut out,
3563-
it,
3564-
&[],
3565-
Some(&tydef.type_),
3566-
AssocItemLink::GotoSource(t_did, &FxHashSet::default()),
3567-
"",
3568-
);
3569-
out.push_str(";</span>");
3570-
}
3571-
}
3572-
}
3573-
}
3574-
}
3575-
}
3576-
3577-
if !out.is_empty() {
3578-
out.insert_str(
3579-
0,
3580-
&format!(
3581-
"<div class=\"important-traits\"><div class='tooltip'>ⓘ\
3582-
<span class='tooltiptext'>Important traits for {}</span></div>\
3583-
<div class=\"content hidden\">",
3584-
trait_
3585-
),
3586-
);
3587-
out.push_str("</code></div></div>");
3588-
}
3589-
3590-
out.into_inner()
3591-
}
3592-
35933517
fn render_impl(
35943518
w: &mut Buffer,
35953519
cx: &Context,
@@ -3696,14 +3620,13 @@ fn render_impl(
36963620
(true, " hidden")
36973621
};
36983622
match item.inner {
3699-
clean::MethodItem(clean::Method { ref decl, .. })
3700-
| clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
3623+
clean::MethodItem(clean::Method { .. })
3624+
| clean::TyMethodItem(clean::TyMethod { .. }) => {
37013625
// Only render when the method is not static or we allow static methods
37023626
if render_method_item {
37033627
let id = cx.derive_id(format!("{}.{}", item_type, name));
37043628
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
37053629
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class);
3706-
write!(w, "{}", spotlight_decl(decl));
37073630
write!(w, "<code id='{}'>", ns_id);
37083631
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl);
37093632
write!(w, "</code>");

src/librustdoc/html/static/main.js

-28
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ function getSearchElement() {
341341
function handleEscape(ev) {
342342
var help = getHelpElement();
343343
var search = getSearchElement();
344-
hideModal();
345344
if (hasClass(help, "hidden") === false) {
346345
displayHelp(false, ev, help);
347346
} else if (hasClass(search, "hidden") === false) {
@@ -373,7 +372,6 @@ function getSearchElement() {
373372
case "s":
374373
case "S":
375374
displayHelp(false, ev);
376-
hideModal();
377375
ev.preventDefault();
378376
focusSearchBar();
379377
break;
@@ -386,7 +384,6 @@ function getSearchElement() {
386384

387385
case "?":
388386
if (ev.shiftKey) {
389-
hideModal();
390387
displayHelp(true, ev);
391388
}
392389
break;
@@ -2504,31 +2501,6 @@ function getSearchElement() {
25042501
lineNumbersFunc(e);
25052502
});
25062503

2507-
function showModal(content) {
2508-
var modal = document.createElement("div");
2509-
modal.id = "important";
2510-
addClass(modal, "modal");
2511-
modal.innerHTML = "<div class=\"modal-content\"><div class=\"close\" id=\"modal-close\">✕" +
2512-
"</div><div class=\"whiter\"></div><span class=\"docblock\">" + content +
2513-
"</span></div>";
2514-
document.getElementsByTagName("body")[0].appendChild(modal);
2515-
document.getElementById("modal-close").onclick = hideModal;
2516-
modal.onclick = hideModal;
2517-
}
2518-
2519-
function hideModal() {
2520-
var modal = document.getElementById("important");
2521-
if (modal) {
2522-
modal.parentNode.removeChild(modal);
2523-
}
2524-
}
2525-
2526-
onEachLazy(document.getElementsByClassName("important-traits"), function(e) {
2527-
e.onclick = function() {
2528-
showModal(e.lastElementChild.innerHTML);
2529-
};
2530-
});
2531-
25322504
// In the search display, allows to switch between tabs.
25332505
function printTab(nb) {
25342506
if (nb === 0 || nb === 1 || nb === 2) {

0 commit comments

Comments
 (0)