Skip to content

Commit

Permalink
rename to doc(notable)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Oct 17, 2023
1 parent 8576693 commit 2033e9d
Show file tree
Hide file tree
Showing 41 changed files with 161 additions and 102 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
cfg => doc_cfg
cfg_hide => doc_cfg_hide
masked => doc_masked
notable_trait => doc_notable_trait
notable => doc_notable_trait
);

if nested_meta.has_name(sym::keyword) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ declare_features! (
(removed, doc_primitive, "1.56.0", Some(88070), None,
Some("merged into `#![feature(rustdoc_internals)]`")),
/// Allows `#[doc(spotlight)]`.
/// The attribute was renamed to `#[doc(notable_trait)]`
/// The attribute was renamed to `#[doc(notable)]`
/// and the feature to `doc_notable_trait`.
(removed, doc_spotlight, "1.22.0", Some(45040), None,
Some("renamed to `doc_notable_trait`")),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ declare_features! (
(unstable, auto_traits, "1.50.0", Some(13231), None),
/// Allows using `box` in patterns (RFC 469).
(unstable, box_patterns, "1.0.0", Some(29641), None),
/// Allows `#[doc(notable_trait)]`.
/// Allows `#[doc(notable)]`.
/// Renamed from `doc_spotlight`.
(unstable, doc_notable_trait, "1.52.0", Some(45040), None),
/// Allows using the `may_dangle` attribute (RFC 1327).
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,9 @@ rustc_queries! {
separate_provide_extern
}

/// Determines whether an item is annotated with `doc(notable_trait)`.
query is_doc_notable_trait(def_id: DefId) -> bool {
desc { |tcx| "checking whether `{}` is `doc(notable_trait)`", tcx.def_path_str(def_id) }
/// Determines whether an item is annotated with `doc(notable)`.
query is_doc_notable(def_id: DefId) -> bool {
desc { |tcx| "checking whether `{}` is `doc(notable)`", tcx.def_path_str(def_id) }
}

/// Returns the attributes on the item at `def_id`.
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,11 +1432,11 @@ fn is_doc_hidden(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
.any(|items| items.iter().any(|item| item.has_name(sym::hidden)))
}

/// Determines whether an item is annotated with `doc(notable_trait)`.
pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
/// Determines whether an item is annotated with `doc(notable)`.
pub fn is_doc_notable(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
tcx.get_attrs(def_id, sym::doc)
.filter_map(|attr| attr.meta_item_list())
.any(|items| items.iter().any(|item| item.has_name(sym::notable_trait)))
.any(|items| items.iter().any(|item| item.has_name(sym::notable)))
}

/// Determines whether an item is an intrinsic by Abi.
Expand All @@ -1448,7 +1448,7 @@ pub fn provide(providers: &mut Providers) {
*providers = Providers {
reveal_opaque_types_in_bounds,
is_doc_hidden,
is_doc_notable_trait,
is_doc_notable,
is_intrinsic,
..*providers
}
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,16 @@ passes_doc_test_unknown_include =
unknown `doc` attribute `{$path}`
.suggestion = use `doc = include_str!` instead
passes_doc_test_unknown_notable_trait =
unknown `doc` attribute `{$path}`
.note = `doc(notable_trait)` was renamed to `doc(notable)`
.suggestion = use `notable` instead
.no_op_note = `doc(notable_trait)` is now a no-op
passes_doc_test_unknown_spotlight =
unknown `doc` attribute `{$path}`
.note = `doc(spotlight)` was renamed to `doc(notable_trait)`
.suggestion = use `notable_trait` instead
.note = `doc(spotlight)` was renamed to `doc(notable)`
.suggestion = use `notable` instead
.no_op_note = `doc(spotlight)` is now a no-op
passes_duplicate_diagnostic_item_in_crate =
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ impl CheckAttrVisitor<'_> {
| sym::masked
| sym::no_default_passes
| sym::no_inline
| sym::notable_trait
| sym::notable
| sym::passes
| sym::plugins
| sym::fake_variadic => {}
Expand Down Expand Up @@ -1189,6 +1189,13 @@ impl CheckAttrVisitor<'_> {
i_meta.span,
errors::DocTestUnknownSpotlight { path, span: i_meta.span },
);
} else if i_meta.has_name(sym::notable_trait) {
self.tcx.emit_spanned_lint(
INVALID_DOC_ATTRIBUTES,
hir_id,
i_meta.span,
errors::DocTestUnknownNotableTrait { path, span: i_meta.span },
);
} else if i_meta.has_name(sym::include)
&& let Some(value) = i_meta.value_str()
{
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,23 @@ pub struct DocTestUnknownAny {
pub path: String,
}

#[derive(LintDiagnostic)]
#[diag(passes_doc_test_unknown_notable_trait)]
#[note]
#[note(passes_no_op_note)]
pub struct DocTestUnknownNotableTrait {
pub path: String,
#[suggestion(style = "short", applicability = "machine-applicable", code = "notable")]
pub span: Span,
}

#[derive(LintDiagnostic)]
#[diag(passes_doc_test_unknown_spotlight)]
#[note]
#[note(passes_no_op_note)]
pub struct DocTestUnknownSpotlight {
pub path: String,
#[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")]
#[suggestion(style = "short", applicability = "machine-applicable", code = "notable")]
pub span: Span,
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ symbols! {
noreturn,
nostack,
not,
notable,
notable_trait,
note,
object_safe_for_dispatch,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,7 @@ impl<'a> Formatter<'a> {
}

#[stable(since = "1.2.0", feature = "formatter_write")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for Formatter<'_> {
fn write_str(&mut self, s: &str) -> Result {
self.buf.write_str(s)
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::task::{Context, Poll};
///
/// [`async`]: ../../std/keyword.async.html
/// [`Waker`]: crate::task::Waker
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[stable(feature = "futures_api", since = "1.36.0")]
#[lang = "future_trait"]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
label = "`{Self}` is not an iterator",
message = "`{Self}` is not an iterator"
)]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
#[rustc_diagnostic_item = "Iterator"]
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub trait Iterator {
Expand Down
12 changes: 6 additions & 6 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ fn buffer_capacity_required(mut file: &File) -> Option<usize> {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for &File {
#[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
Expand Down Expand Up @@ -785,7 +785,7 @@ impl Read for &File {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for &File {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.write(buf)
Expand Down Expand Up @@ -813,7 +813,7 @@ impl Seek for &File {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for File {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
(&*self).read(buf)
Expand All @@ -836,7 +836,7 @@ impl Read for File {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for File {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(&*self).write(buf)
Expand All @@ -861,7 +861,7 @@ impl Seek for File {
}

#[stable(feature = "io_traits_arc", since = "1.73.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for Arc<File> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
(&**self).read(buf)
Expand All @@ -884,7 +884,7 @@ impl Read for Arc<File> {
}
}
#[stable(feature = "io_traits_arc", since = "1.73.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for Arc<File> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(&**self).write(buf)
Expand Down
10 changes: 5 additions & 5 deletions library/std/src/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ where
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for Cursor<&mut [u8]> {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
Expand All @@ -544,7 +544,7 @@ impl Write for Cursor<&mut [u8]> {
}

#[stable(feature = "cursor_mut_vec", since = "1.25.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl<A> Write for Cursor<&mut Vec<u8, A>>
where
A: Allocator,
Expand All @@ -569,7 +569,7 @@ where
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl<A> Write for Cursor<Vec<u8, A>>
where
A: Allocator,
Expand All @@ -594,7 +594,7 @@ where
}

#[stable(feature = "cursor_box_slice", since = "1.5.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl<A> Write for Cursor<Box<[u8], A>>
where
A: Allocator,
Expand All @@ -621,7 +621,7 @@ where
}

#[stable(feature = "cursor_array", since = "1.61.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl<const N: usize> Write for Cursor<[u8; N]> {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
Expand Down
16 changes: 8 additions & 8 deletions library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl fmt::Debug for Stdin {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for Stdin {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.lock().read(buf)
Expand Down Expand Up @@ -453,7 +453,7 @@ impl StdinLock<'_> {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for StdinLock<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.read(buf)
Expand Down Expand Up @@ -679,7 +679,7 @@ impl fmt::Debug for Stdout {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for Stdout {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(&*self).write(buf)
Expand All @@ -706,7 +706,7 @@ impl Write for Stdout {
}

#[stable(feature = "write_mt", since = "1.48.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for &Stdout {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.lock().write(buf)
Expand All @@ -733,7 +733,7 @@ impl Write for &Stdout {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for StdoutLock<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.borrow_mut().write(buf)
Expand Down Expand Up @@ -902,7 +902,7 @@ impl fmt::Debug for Stderr {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for Stderr {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
(&*self).write(buf)
Expand All @@ -929,7 +929,7 @@ impl Write for Stderr {
}

#[stable(feature = "write_mt", since = "1.48.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for &Stderr {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.lock().write(buf)
Expand All @@ -956,7 +956,7 @@ impl Write for &Stderr {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for StderrLock<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.borrow_mut().write(buf)
Expand Down
8 changes: 4 additions & 4 deletions library/std/src/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub const fn empty() -> Empty {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for Empty {
#[inline]
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
Expand Down Expand Up @@ -180,7 +180,7 @@ pub const fn repeat(byte: u8) -> Repeat {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Read for Repeat {
#[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
Expand Down Expand Up @@ -274,7 +274,7 @@ pub const fn sink() -> Sink {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for Sink {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
Expand All @@ -299,7 +299,7 @@ impl Write for Sink {
}

#[stable(feature = "write_mt", since = "1.48.0")]
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(notable))]
impl Write for &Sink {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
Expand Down
Loading

0 comments on commit 2033e9d

Please sign in to comment.