Skip to content

Commit 1244ced

Browse files
Remove "important traits" feature
1 parent 01a8b5f commit 1244ced

File tree

15 files changed

+7
-391
lines changed

15 files changed

+7
-391
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/librustc_feature/active.rs

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

366-
/// Allows `#[doc(spotlight)]`.
367-
(active, doc_spotlight, "1.22.0", Some(45040), None),
368-
369366
/// Allows `#[doc(include = "some-file")]`.
370367
(active, external_doc, "1.22.0", Some(44732), None),
371368

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
@@ -952,7 +952,6 @@ pub struct Trait {
952952
pub items: Vec<Item>,
953953
pub generics: Generics,
954954
pub bounds: Vec<GenericBound>,
955-
pub is_spotlight: bool,
956955
pub is_auto: bool,
957956
}
958957

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
@@ -2324,7 +2324,7 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
23242324
f.generics.print()
23252325
)
23262326
.len();
2327-
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it));
2327+
write!(w, "<pre class='rust fn'>");
23282328
render_attributes(w, it, false);
23292329
write!(
23302330
w,
@@ -2527,13 +2527,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait)
25272527
let item_type = m.type_();
25282528
let id = cx.derive_id(format!("{}.{}", item_type, name));
25292529
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
2530-
write!(
2531-
w,
2532-
"<h3 id='{id}' class='method'>{extra}<code id='{ns_id}'>",
2533-
extra = render_spotlight_traits(m),
2534-
id = id,
2535-
ns_id = ns_id
2536-
);
2530+
write!(w, "<h3 id='{id}' class='method'><code id='{ns_id}'>", id = id, ns_id = ns_id);
25372531
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
25382532
write!(w, "</code>");
25392533
render_stability_since(w, m, t);
@@ -3519,76 +3513,6 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
35193513
}
35203514
}
35213515

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