Skip to content

Commit 9055128

Browse files
committed
notable trait for impls
1 parent bd4a96a commit 9055128

File tree

10 files changed

+36
-2
lines changed

10 files changed

+36
-2
lines changed

library/core/src/fmt/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,7 @@ impl<'a> Formatter<'a> {
23652365
}
23662366

23672367
#[stable(since = "1.2.0", feature = "formatter_write")]
2368+
#[doc(notable_trait)]
23682369
impl Write for Formatter<'_> {
23692370
fn write_str(&mut self, s: &str) -> Result {
23702371
self.buf.write_str(s)

library/std/src/fs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ fn buffer_capacity_required(mut file: &File) -> usize {
741741
}
742742

743743
#[stable(feature = "rust1", since = "1.0.0")]
744+
#[doc(notable_trait)]
744745
impl Read for File {
745746
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
746747
self.inner.read(buf)
@@ -772,6 +773,7 @@ impl Read for File {
772773
}
773774
}
774775
#[stable(feature = "rust1", since = "1.0.0")]
776+
#[doc(notable_trait)]
775777
impl Write for File {
776778
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
777779
self.inner.write(buf)
@@ -797,6 +799,7 @@ impl Seek for File {
797799
}
798800
}
799801
#[stable(feature = "rust1", since = "1.0.0")]
802+
#[doc(notable_trait)]
800803
impl Read for &File {
801804
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
802805
self.inner.read(buf)
@@ -828,6 +831,7 @@ impl Read for &File {
828831
}
829832
}
830833
#[stable(feature = "rust1", since = "1.0.0")]
834+
#[doc(notable_trait)]
831835
impl Write for &File {
832836
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
833837
self.inner.write(buf)

library/std/src/io/cursor.rs

+5
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ where
520520
}
521521

522522
#[stable(feature = "rust1", since = "1.0.0")]
523+
#[doc(notable_trait)]
523524
impl Write for Cursor<&mut [u8]> {
524525
#[inline]
525526
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
@@ -543,6 +544,7 @@ impl Write for Cursor<&mut [u8]> {
543544
}
544545

545546
#[stable(feature = "cursor_mut_vec", since = "1.25.0")]
547+
#[doc(notable_trait)]
546548
impl<A> Write for Cursor<&mut Vec<u8, A>>
547549
where
548550
A: Allocator,
@@ -567,6 +569,7 @@ where
567569
}
568570

569571
#[stable(feature = "rust1", since = "1.0.0")]
572+
#[doc(notable_trait)]
570573
impl<A> Write for Cursor<Vec<u8, A>>
571574
where
572575
A: Allocator,
@@ -591,6 +594,7 @@ where
591594
}
592595

593596
#[stable(feature = "cursor_box_slice", since = "1.5.0")]
597+
#[doc(notable_trait)]
594598
impl<A> Write for Cursor<Box<[u8], A>>
595599
where
596600
A: Allocator,
@@ -617,6 +621,7 @@ where
617621
}
618622

619623
#[stable(feature = "cursor_array", since = "1.61.0")]
624+
#[doc(notable_trait)]
620625
impl<const N: usize> Write for Cursor<[u8; N]> {
621626
#[inline]
622627
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {

library/std/src/io/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ where
549549
/// [`std::io`]: self
550550
/// [`File`]: crate::fs::File
551551
#[stable(feature = "rust1", since = "1.0.0")]
552-
#[doc(notable_trait)]
553552
#[cfg_attr(not(test), rustc_diagnostic_item = "IoRead")]
554553
pub trait Read {
555554
/// Pull some bytes from this source into the specified buffer, returning
@@ -1380,7 +1379,6 @@ impl<'a> Deref for IoSlice<'a> {
13801379
///
13811380
/// [`write_all`]: Write::write_all
13821381
#[stable(feature = "rust1", since = "1.0.0")]
1383-
#[doc(notable_trait)]
13841382
#[cfg_attr(not(test), rustc_diagnostic_item = "IoWrite")]
13851383
pub trait Write {
13861384
/// Write a buffer into this writer, returning how many bytes were written.

library/std/src/io/stdio.rs

+8
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl fmt::Debug for Stdin {
414414
}
415415

416416
#[stable(feature = "rust1", since = "1.0.0")]
417+
#[doc(notable_trait)]
417418
impl Read for Stdin {
418419
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
419420
self.lock().read(buf)
@@ -445,6 +446,7 @@ impl StdinLock<'_> {
445446
}
446447

447448
#[stable(feature = "rust1", since = "1.0.0")]
449+
#[doc(notable_trait)]
448450
impl Read for StdinLock<'_> {
449451
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
450452
self.inner.read(buf)
@@ -665,6 +667,7 @@ impl fmt::Debug for Stdout {
665667
}
666668

667669
#[stable(feature = "rust1", since = "1.0.0")]
670+
#[doc(notable_trait)]
668671
impl Write for Stdout {
669672
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
670673
(&*self).write(buf)
@@ -691,6 +694,7 @@ impl Write for Stdout {
691694
}
692695

693696
#[stable(feature = "write_mt", since = "1.48.0")]
697+
#[doc(notable_trait)]
694698
impl Write for &Stdout {
695699
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
696700
self.lock().write(buf)
@@ -717,6 +721,7 @@ impl Write for &Stdout {
717721
}
718722

719723
#[stable(feature = "rust1", since = "1.0.0")]
724+
#[doc(notable_trait)]
720725
impl Write for StdoutLock<'_> {
721726
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
722727
self.inner.borrow_mut().write(buf)
@@ -884,6 +889,7 @@ impl fmt::Debug for Stderr {
884889
}
885890

886891
#[stable(feature = "rust1", since = "1.0.0")]
892+
#[doc(notable_trait)]
887893
impl Write for Stderr {
888894
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
889895
(&*self).write(buf)
@@ -910,6 +916,7 @@ impl Write for Stderr {
910916
}
911917

912918
#[stable(feature = "write_mt", since = "1.48.0")]
919+
#[doc(notable_trait)]
913920
impl Write for &Stderr {
914921
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
915922
self.lock().write(buf)
@@ -936,6 +943,7 @@ impl Write for &Stderr {
936943
}
937944

938945
#[stable(feature = "rust1", since = "1.0.0")]
946+
#[doc(notable_trait)]
939947
impl Write for StderrLock<'_> {
940948
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
941949
self.inner.borrow_mut().write(buf)

library/std/src/io/util.rs

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub const fn empty() -> Empty {
4040
}
4141

4242
#[stable(feature = "rust1", since = "1.0.0")]
43+
#[doc(notable_trait)]
4344
impl Read for Empty {
4445
#[inline]
4546
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
@@ -121,6 +122,7 @@ pub const fn repeat(byte: u8) -> Repeat {
121122
}
122123

123124
#[stable(feature = "rust1", since = "1.0.0")]
125+
#[doc(notable_trait)]
124126
impl Read for Repeat {
125127
#[inline]
126128
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
@@ -213,6 +215,7 @@ pub const fn sink() -> Sink {
213215
}
214216

215217
#[stable(feature = "rust1", since = "1.0.0")]
218+
#[doc(notable_trait)]
216219
impl Write for Sink {
217220
#[inline]
218221
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
@@ -237,6 +240,7 @@ impl Write for Sink {
237240
}
238241

239242
#[stable(feature = "write_mt", since = "1.48.0")]
243+
#[doc(notable_trait)]
240244
impl Write for &Sink {
241245
#[inline]
242246
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {

library/std/src/net/tcp.rs

+4
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ impl TcpStream {
614614
// `AsRawSocket`/`IntoRawSocket`/`FromRawSocket` on Windows.
615615

616616
#[stable(feature = "rust1", since = "1.0.0")]
617+
#[doc(notable_trait)]
617618
impl Read for TcpStream {
618619
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
619620
self.0.read(buf)
@@ -629,6 +630,7 @@ impl Read for TcpStream {
629630
}
630631
}
631632
#[stable(feature = "rust1", since = "1.0.0")]
633+
#[doc(notable_trait)]
632634
impl Write for TcpStream {
633635
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
634636
self.0.write(buf)
@@ -648,6 +650,7 @@ impl Write for TcpStream {
648650
}
649651
}
650652
#[stable(feature = "rust1", since = "1.0.0")]
653+
#[doc(notable_trait)]
651654
impl Read for &TcpStream {
652655
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
653656
self.0.read(buf)
@@ -663,6 +666,7 @@ impl Read for &TcpStream {
663666
}
664667
}
665668
#[stable(feature = "rust1", since = "1.0.0")]
669+
#[doc(notable_trait)]
666670
impl Write for &TcpStream {
667671
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
668672
self.0.write(buf)

library/std/src/process.rs

+4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ pub struct ChildStdin {
266266
// `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows.
267267

268268
#[stable(feature = "process", since = "1.0.0")]
269+
#[doc(notable_trait)]
269270
impl Write for ChildStdin {
270271
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
271272
(&*self).write(buf)
@@ -285,6 +286,7 @@ impl Write for ChildStdin {
285286
}
286287

287288
#[stable(feature = "write_mt", since = "1.48.0")]
289+
#[doc(notable_trait)]
288290
impl Write for &ChildStdin {
289291
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
290292
self.inner.write(buf)
@@ -349,6 +351,7 @@ pub struct ChildStdout {
349351
// `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows.
350352

351353
#[stable(feature = "process", since = "1.0.0")]
354+
#[doc(notable_trait)]
352355
impl Read for ChildStdout {
353356
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
354357
self.inner.read(buf)
@@ -414,6 +417,7 @@ pub struct ChildStderr {
414417
// `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows.
415418

416419
#[stable(feature = "process", since = "1.0.0")]
420+
#[doc(notable_trait)]
417421
impl Read for ChildStderr {
418422
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
419423
self.inner.read(buf)

src/librustdoc/formats/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub(crate) mod item_type;
33
pub(crate) mod renderer;
44

55
use rustc_hir::def_id::DefId;
6+
use rustc_span::sym;
67

78
pub(crate) use renderer::{run_format, FormatRenderer};
89

@@ -38,6 +39,10 @@ impl Impl {
3839
}
3940
}
4041

42+
pub(crate) fn is_notable(&self) -> bool {
43+
self.impl_item.attrs.has_doc_flag(sym::notable_trait)
44+
}
45+
4146
pub(crate) fn trait_did(&self) -> Option<DefId> {
4247
self.inner_impl().trait_.as_ref().map(|t| t.def_id())
4348
}

src/librustdoc/html/render/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O
13001300
let trait_did = trait_.def_id();
13011301

13021302
if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable_trait(cx.tcx()))
1303+
|| i.is_notable()
13031304
{
13041305
has_notable_trait = true;
13051306
}

0 commit comments

Comments
 (0)