diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index c9821bf8109a7..ac93ad54a4a69 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2365,6 +2365,7 @@ impl<'a> Formatter<'a> { } #[stable(since = "1.2.0", feature = "formatter_write")] +#[doc(notable_trait)] impl Write for Formatter<'_> { fn write_str(&mut self, s: &str) -> Result { self.buf.write_str(s) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index c550378e7d6b7..58e3345f2c589 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -741,6 +741,7 @@ fn buffer_capacity_required(mut file: &File) -> usize { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for File { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) @@ -772,6 +773,7 @@ impl Read for File { } } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for File { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) @@ -797,6 +799,7 @@ impl Seek for File { } } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for &File { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) @@ -828,6 +831,7 @@ impl Read for &File { } } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for &File { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) diff --git a/library/std/src/io/cursor.rs b/library/std/src/io/cursor.rs index d98ab021cadb1..6353da67fef8a 100644 --- a/library/std/src/io/cursor.rs +++ b/library/std/src/io/cursor.rs @@ -520,6 +520,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for Cursor<&mut [u8]> { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { @@ -543,6 +544,7 @@ impl Write for Cursor<&mut [u8]> { } #[stable(feature = "cursor_mut_vec", since = "1.25.0")] +#[doc(notable_trait)] impl Write for Cursor<&mut Vec> where A: Allocator, @@ -567,6 +569,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for Cursor> where A: Allocator, @@ -591,6 +594,7 @@ where } #[stable(feature = "cursor_box_slice", since = "1.5.0")] +#[doc(notable_trait)] impl Write for Cursor> where A: Allocator, @@ -617,6 +621,7 @@ where } #[stable(feature = "cursor_array", since = "1.61.0")] +#[doc(notable_trait)] impl Write for Cursor<[u8; N]> { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index b2b6d86134b62..0304a503bdede 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -549,7 +549,6 @@ where /// [`std::io`]: self /// [`File`]: crate::fs::File #[stable(feature = "rust1", since = "1.0.0")] -#[doc(notable_trait)] #[cfg_attr(not(test), rustc_diagnostic_item = "IoRead")] pub trait Read { /// Pull some bytes from this source into the specified buffer, returning @@ -1380,7 +1379,6 @@ impl<'a> Deref for IoSlice<'a> { /// /// [`write_all`]: Write::write_all #[stable(feature = "rust1", since = "1.0.0")] -#[doc(notable_trait)] #[cfg_attr(not(test), rustc_diagnostic_item = "IoWrite")] pub trait Write { /// Write a buffer into this writer, returning how many bytes were written. diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 14bfef4c7aad9..f01062bba9174 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -414,6 +414,7 @@ impl fmt::Debug for Stdin { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.lock().read(buf) @@ -445,6 +446,7 @@ impl StdinLock<'_> { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for StdinLock<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) @@ -665,6 +667,7 @@ impl fmt::Debug for Stdout { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for Stdout { fn write(&mut self, buf: &[u8]) -> io::Result { (&*self).write(buf) @@ -691,6 +694,7 @@ impl Write for Stdout { } #[stable(feature = "write_mt", since = "1.48.0")] +#[doc(notable_trait)] impl Write for &Stdout { fn write(&mut self, buf: &[u8]) -> io::Result { self.lock().write(buf) @@ -717,6 +721,7 @@ impl Write for &Stdout { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for StdoutLock<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.borrow_mut().write(buf) @@ -884,6 +889,7 @@ impl fmt::Debug for Stderr { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for Stderr { fn write(&mut self, buf: &[u8]) -> io::Result { (&*self).write(buf) @@ -910,6 +916,7 @@ impl Write for Stderr { } #[stable(feature = "write_mt", since = "1.48.0")] +#[doc(notable_trait)] impl Write for &Stderr { fn write(&mut self, buf: &[u8]) -> io::Result { self.lock().write(buf) @@ -936,6 +943,7 @@ impl Write for &Stderr { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for StderrLock<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.borrow_mut().write(buf) diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index f076ee0923c80..7f380fe88e8d2 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -40,6 +40,7 @@ pub const fn empty() -> Empty { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for Empty { #[inline] fn read(&mut self, _buf: &mut [u8]) -> io::Result { @@ -121,6 +122,7 @@ pub const fn repeat(byte: u8) -> Repeat { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for Repeat { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { @@ -213,6 +215,7 @@ pub const fn sink() -> Sink { } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for Sink { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { @@ -237,6 +240,7 @@ impl Write for Sink { } #[stable(feature = "write_mt", since = "1.48.0")] +#[doc(notable_trait)] impl Write for &Sink { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index ac09a805975ef..f737b05ce7787 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -614,6 +614,7 @@ impl TcpStream { // `AsRawSocket`/`IntoRawSocket`/`FromRawSocket` on Windows. #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for TcpStream { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.0.read(buf) @@ -629,6 +630,7 @@ impl Read for TcpStream { } } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for TcpStream { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.write(buf) @@ -648,6 +650,7 @@ impl Write for TcpStream { } } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Read for &TcpStream { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.0.read(buf) @@ -663,6 +666,7 @@ impl Read for &TcpStream { } } #[stable(feature = "rust1", since = "1.0.0")] +#[doc(notable_trait)] impl Write for &TcpStream { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.write(buf) diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 62ce2cb33dc55..acfb8bc16d6f7 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -266,6 +266,7 @@ pub struct ChildStdin { // `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows. #[stable(feature = "process", since = "1.0.0")] +#[doc(notable_trait)] impl Write for ChildStdin { fn write(&mut self, buf: &[u8]) -> io::Result { (&*self).write(buf) @@ -285,6 +286,7 @@ impl Write for ChildStdin { } #[stable(feature = "write_mt", since = "1.48.0")] +#[doc(notable_trait)] impl Write for &ChildStdin { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) @@ -349,6 +351,7 @@ pub struct ChildStdout { // `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows. #[stable(feature = "process", since = "1.0.0")] +#[doc(notable_trait)] impl Read for ChildStdout { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) @@ -414,6 +417,7 @@ pub struct ChildStderr { // `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows. #[stable(feature = "process", since = "1.0.0")] +#[doc(notable_trait)] impl Read for ChildStderr { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) diff --git a/src/librustdoc/formats/mod.rs b/src/librustdoc/formats/mod.rs index e607a16ad5457..da82154131f92 100644 --- a/src/librustdoc/formats/mod.rs +++ b/src/librustdoc/formats/mod.rs @@ -3,6 +3,7 @@ pub(crate) mod item_type; pub(crate) mod renderer; use rustc_hir::def_id::DefId; +use rustc_span::sym; pub(crate) use renderer::{run_format, FormatRenderer}; @@ -38,6 +39,10 @@ impl Impl { } } + pub(crate) fn is_notable(&self) -> bool { + self.impl_item.attrs.has_doc_flag(sym::notable_trait) + } + pub(crate) fn trait_did(&self) -> Option { self.inner_impl().trait_.as_ref().map(|t| t.def_id()) } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index e6a040d02e565..4a8e233f0063c 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1300,6 +1300,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O let trait_did = trait_.def_id(); if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable_trait(cx.tcx())) + || i.is_notable() { has_notable_trait = true; }