Skip to content

Commit 34c6cee

Browse files
committed
Rename #[doc(spotlight)] to #[doc(notable_trait)]
"spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation
1 parent 2ccf063 commit 34c6cee

File tree

23 files changed

+153
-88
lines changed

23 files changed

+153
-88
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
313313
include => external_doc
314314
cfg => doc_cfg
315315
masked => doc_masked
316-
spotlight => doc_spotlight
316+
notable_trait => doc_notable_trait
317317
keyword => doc_keyword
318318
);
319319
}

compiler/rustc_feature/src/active.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ declare_features! (
216216
/// Renamed from `optin_builtin_traits`.
217217
(active, auto_traits, "1.50.0", Some(13231), None),
218218

219+
/// Allows `#[doc(notable_trait)]`.
220+
/// Renamed from `doc_spotlight`.
221+
(active, doc_notable_trait, "1.52.0", Some(45040), None),
222+
219223
// no-tracking-issue-end
220224

221225
// -------------------------------------------------------------------------
@@ -374,9 +378,6 @@ declare_features! (
374378
/// Allows `#[doc(masked)]`.
375379
(active, doc_masked, "1.21.0", Some(44027), None),
376380

377-
/// Allows `#[doc(spotlight)]`.
378-
(active, doc_spotlight, "1.22.0", Some(45040), None),
379-
380381
/// Allows `#[doc(include = "some-file")]`.
381382
(active, external_doc, "1.22.0", Some(44732), None),
382383

compiler/rustc_feature/src/removed.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ declare_features! (
8080
Some("subsumed by `#![feature(allocator_internals)]`")),
8181
/// Allows identifying crates that contain sanitizer runtimes.
8282
(removed, sanitizer_runtime, "1.17.0", None, None, None),
83+
/// Allows `#[doc(spotlight)]`.
84+
/// The attribute was renamed to `#[doc(notable_trait)]`
85+
/// and the feature to `doc_notable_trait`.
86+
(removed, doc_spotlight, "1.22.0", Some(45040), None,
87+
Some("renamed to `doc_notable_trait`")),
8388
(removed, proc_macro_mod, "1.27.0", Some(54727), None,
8489
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
8590
(removed, proc_macro_expr, "1.27.0", Some(54727), None,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::query::Providers;
99
use rustc_middle::ty::TyCtxt;
1010

1111
use rustc_ast::{Attribute, Lit, LitKind, NestedMetaItem};
12-
use rustc_errors::{pluralize, struct_span_err};
12+
use rustc_errors::{pluralize, struct_span_err, Applicability};
1313
use rustc_hir as hir;
1414
use rustc_hir::def_id::LocalDefId;
1515
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
@@ -589,10 +589,10 @@ impl CheckAttrVisitor<'tcx> {
589589
| sym::masked
590590
| sym::no_default_passes
591591
| sym::no_inline
592+
| sym::notable_trait
592593
| sym::passes
593594
| sym::plugins
594595
| sym::primitive
595-
| sym::spotlight
596596
| sym::test => {}
597597

598598
_ => {
@@ -601,11 +601,23 @@ impl CheckAttrVisitor<'tcx> {
601601
hir_id,
602602
i_meta.span,
603603
|lint| {
604-
let msg = format!(
604+
let mut diag = lint.build(&format!(
605605
"unknown `doc` attribute `{}`",
606606
rustc_ast_pretty::pprust::path_to_string(&i_meta.path),
607-
);
608-
lint.build(&msg).emit();
607+
));
608+
if i_meta.has_name(sym::spotlight) {
609+
diag.note(
610+
"`doc(spotlight)` was renamed to `doc(notable_trait)`",
611+
);
612+
diag.span_suggestion_short(
613+
i_meta.span,
614+
"use `notable_trait` instead",
615+
String::from("notable_trait"),
616+
Applicability::MachineApplicable,
617+
);
618+
diag.note("`doc(spotlight)` is now a no-op");
619+
}
620+
diag.emit();
609621
},
610622
);
611623
is_valid = false;

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ symbols! {
476476
doc_cfg,
477477
doc_keyword,
478478
doc_masked,
479+
doc_notable_trait,
479480
doc_spotlight,
480481
doctest,
481482
document_private_items,
@@ -799,6 +800,7 @@ symbols! {
799800
noreturn,
800801
nostack,
801802
not,
803+
notable_trait,
802804
note,
803805
object_safe_for_dispatch,
804806
of,

library/core/src/future/future.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use crate::task::{Context, Poll};
2424
/// `.await` the value.
2525
///
2626
/// [`Waker`]: crate::task::Waker
27-
#[doc(spotlight)]
27+
#[cfg_attr(bootstrap, doc(spotlight))]
28+
#[cfg_attr(not(bootstrap), doc(notable_trait))]
2829
#[must_use = "futures do nothing unless you `.await` or poll them"]
2930
#[stable(feature = "futures_api", since = "1.36.0")]
3031
#[lang = "future_trait"]

library/core/src/iter/traits/iterator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ 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)]
95+
#[cfg_attr(bootstrap, doc(spotlight))]
96+
#[cfg_attr(not(bootstrap), doc(notable_trait))]
9697
#[rustc_diagnostic_item = "Iterator"]
9798
#[must_use = "iterators are lazy and do nothing unless consumed"]
9899
pub trait Iterator {

library/core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108
#![feature(custom_inner_attributes)]
109109
#![feature(decl_macro)]
110110
#![feature(doc_cfg)]
111-
#![feature(doc_spotlight)]
111+
#![cfg_attr(bootstrap, feature(doc_spotlight))]
112+
#![cfg_attr(not(bootstrap), feature(doc_notable_trait))]
112113
#![feature(duration_consts_2)]
113114
#![feature(duration_saturating_ops)]
114115
#![feature(extended_key_value_attributes)]

library/std/src/io/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ pub(crate) fn default_read_exact<R: Read + ?Sized>(this: &mut R, mut buf: &mut [
505505
/// [`std::io`]: self
506506
/// [`File`]: crate::fs::File
507507
#[stable(feature = "rust1", since = "1.0.0")]
508-
#[doc(spotlight)]
508+
#[cfg_attr(bootstrap, doc(spotlight))]
509+
#[cfg_attr(not(bootstrap), doc(notable_trait))]
509510
pub trait Read {
510511
/// Pull some bytes from this source into the specified buffer, returning
511512
/// how many bytes were read.
@@ -1291,7 +1292,8 @@ impl Initializer {
12911292
///
12921293
/// [`write_all`]: Write::write_all
12931294
#[stable(feature = "rust1", since = "1.0.0")]
1294-
#[doc(spotlight)]
1295+
#[cfg_attr(bootstrap, doc(spotlight))]
1296+
#[cfg_attr(not(bootstrap), doc(notable_trait))]
12951297
pub trait Write {
12961298
/// Write a buffer into this writer, returning how many bytes were written.
12971299
///

library/std/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@
257257
#![feature(doc_cfg)]
258258
#![feature(doc_keyword)]
259259
#![feature(doc_masked)]
260-
#![feature(doc_spotlight)]
260+
#![cfg_attr(bootstrap, feature(doc_spotlight))]
261+
#![cfg_attr(not(bootstrap), feature(doc_notable_trait))]
261262
#![feature(dropck_eyepatch)]
262263
#![feature(duration_constants)]
263264
#![feature(duration_zero)]

0 commit comments

Comments
 (0)