Skip to content

Commit 8576693

Browse files
committed
notable trait for impls
1 parent ddef56d commit 8576693

File tree

10 files changed

+38
-2
lines changed

10 files changed

+38
-2
lines changed

library/core/src/fmt/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,7 @@ impl<'a> Formatter<'a> {
22602260
}
22612261

22622262
#[stable(since = "1.2.0", feature = "formatter_write")]
2263+
#[doc(notable_trait)]
22632264
impl Write for Formatter<'_> {
22642265
fn write_str(&mut self, s: &str) -> Result {
22652266
self.buf.write_str(s)

library/std/src/fs.rs

+6
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ fn buffer_capacity_required(mut file: &File) -> Option<usize> {
748748
}
749749

750750
#[stable(feature = "rust1", since = "1.0.0")]
751+
#[doc(notable_trait)]
751752
impl Read for &File {
752753
#[inline]
753754
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
@@ -784,6 +785,7 @@ impl Read for &File {
784785
}
785786
}
786787
#[stable(feature = "rust1", since = "1.0.0")]
788+
#[doc(notable_trait)]
787789
impl Write for &File {
788790
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
789791
self.inner.write(buf)
@@ -811,6 +813,7 @@ impl Seek for &File {
811813
}
812814

813815
#[stable(feature = "rust1", since = "1.0.0")]
816+
#[doc(notable_trait)]
814817
impl Read for File {
815818
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
816819
(&*self).read(buf)
@@ -833,6 +836,7 @@ impl Read for File {
833836
}
834837
}
835838
#[stable(feature = "rust1", since = "1.0.0")]
839+
#[doc(notable_trait)]
836840
impl Write for File {
837841
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
838842
(&*self).write(buf)
@@ -857,6 +861,7 @@ impl Seek for File {
857861
}
858862

859863
#[stable(feature = "io_traits_arc", since = "1.73.0")]
864+
#[doc(notable_trait)]
860865
impl Read for Arc<File> {
861866
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
862867
(&**self).read(buf)
@@ -879,6 +884,7 @@ impl Read for Arc<File> {
879884
}
880885
}
881886
#[stable(feature = "io_traits_arc", since = "1.73.0")]
887+
#[doc(notable_trait)]
882888
impl Write for Arc<File> {
883889
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
884890
(&**self).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
@@ -608,7 +608,6 @@ where
608608
/// [`std::io`]: self
609609
/// [`File`]: crate::fs::File
610610
#[stable(feature = "rust1", since = "1.0.0")]
611-
#[doc(notable_trait)]
612611
#[cfg_attr(not(test), rustc_diagnostic_item = "IoRead")]
613612
pub trait Read {
614613
/// Pull some bytes from this source into the specified buffer, returning
@@ -1457,7 +1456,6 @@ impl<'a> Deref for IoSlice<'a> {
14571456
///
14581457
/// [`write_all`]: Write::write_all
14591458
#[stable(feature = "rust1", since = "1.0.0")]
1460-
#[doc(notable_trait)]
14611459
#[cfg_attr(not(test), rustc_diagnostic_item = "IoWrite")]
14621460
pub trait Write {
14631461
/// 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
@@ -418,6 +418,7 @@ impl fmt::Debug for Stdin {
418418
}
419419

420420
#[stable(feature = "rust1", since = "1.0.0")]
421+
#[doc(notable_trait)]
421422
impl Read for Stdin {
422423
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
423424
self.lock().read(buf)
@@ -452,6 +453,7 @@ impl StdinLock<'_> {
452453
}
453454

454455
#[stable(feature = "rust1", since = "1.0.0")]
456+
#[doc(notable_trait)]
455457
impl Read for StdinLock<'_> {
456458
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
457459
self.inner.read(buf)
@@ -677,6 +679,7 @@ impl fmt::Debug for Stdout {
677679
}
678680

679681
#[stable(feature = "rust1", since = "1.0.0")]
682+
#[doc(notable_trait)]
680683
impl Write for Stdout {
681684
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
682685
(&*self).write(buf)
@@ -703,6 +706,7 @@ impl Write for Stdout {
703706
}
704707

705708
#[stable(feature = "write_mt", since = "1.48.0")]
709+
#[doc(notable_trait)]
706710
impl Write for &Stdout {
707711
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
708712
self.lock().write(buf)
@@ -729,6 +733,7 @@ impl Write for &Stdout {
729733
}
730734

731735
#[stable(feature = "rust1", since = "1.0.0")]
736+
#[doc(notable_trait)]
732737
impl Write for StdoutLock<'_> {
733738
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
734739
self.inner.borrow_mut().write(buf)
@@ -897,6 +902,7 @@ impl fmt::Debug for Stderr {
897902
}
898903

899904
#[stable(feature = "rust1", since = "1.0.0")]
905+
#[doc(notable_trait)]
900906
impl Write for Stderr {
901907
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
902908
(&*self).write(buf)
@@ -923,6 +929,7 @@ impl Write for Stderr {
923929
}
924930

925931
#[stable(feature = "write_mt", since = "1.48.0")]
932+
#[doc(notable_trait)]
926933
impl Write for &Stderr {
927934
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
928935
self.lock().write(buf)
@@ -949,6 +956,7 @@ impl Write for &Stderr {
949956
}
950957

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

library/std/src/io/util.rs

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub const fn empty() -> Empty {
5757
}
5858

5959
#[stable(feature = "rust1", since = "1.0.0")]
60+
#[doc(notable_trait)]
6061
impl Read for Empty {
6162
#[inline]
6263
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
@@ -179,6 +180,7 @@ pub const fn repeat(byte: u8) -> Repeat {
179180
}
180181

181182
#[stable(feature = "rust1", since = "1.0.0")]
183+
#[doc(notable_trait)]
182184
impl Read for Repeat {
183185
#[inline]
184186
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
@@ -272,6 +274,7 @@ pub const fn sink() -> Sink {
272274
}
273275

274276
#[stable(feature = "rust1", since = "1.0.0")]
277+
#[doc(notable_trait)]
275278
impl Write for Sink {
276279
#[inline]
277280
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
@@ -296,6 +299,7 @@ impl Write for Sink {
296299
}
297300

298301
#[stable(feature = "write_mt", since = "1.48.0")]
302+
#[doc(notable_trait)]
299303
impl Write for &Sink {
300304
#[inline]
301305
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)
@@ -633,6 +634,7 @@ impl Read for TcpStream {
633634
}
634635
}
635636
#[stable(feature = "rust1", since = "1.0.0")]
637+
#[doc(notable_trait)]
636638
impl Write for TcpStream {
637639
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
638640
self.0.write(buf)
@@ -653,6 +655,7 @@ impl Write for TcpStream {
653655
}
654656
}
655657
#[stable(feature = "rust1", since = "1.0.0")]
658+
#[doc(notable_trait)]
656659
impl Read for &TcpStream {
657660
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
658661
self.0.read(buf)
@@ -672,6 +675,7 @@ impl Read for &TcpStream {
672675
}
673676
}
674677
#[stable(feature = "rust1", since = "1.0.0")]
678+
#[doc(notable_trait)]
675679
impl Write for &TcpStream {
676680
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
677681
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)
@@ -286,6 +287,7 @@ impl Write for ChildStdin {
286287
}
287288

288289
#[stable(feature = "write_mt", since = "1.48.0")]
290+
#[doc(notable_trait)]
289291
impl Write for &ChildStdin {
290292
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
291293
self.inner.write(buf)
@@ -352,6 +354,7 @@ pub struct ChildStdout {
352354
// `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows.
353355

354356
#[stable(feature = "process", since = "1.0.0")]
357+
#[doc(notable_trait)]
355358
impl Read for ChildStdout {
356359
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
357360
self.inner.read(buf)
@@ -422,6 +425,7 @@ pub struct ChildStderr {
422425
// `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows.
423426

424427
#[stable(feature = "process", since = "1.0.0")]
428+
#[doc(notable_trait)]
425429
impl Read for ChildStderr {
426430
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
427431
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
@@ -1345,6 +1345,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O
13451345
let trait_did = trait_.def_id();
13461346

13471347
if cx.cache().traits.get(&trait_did).map_or(false, |t| t.is_notable_trait(cx.tcx()))
1348+
|| i.is_notable()
13481349
{
13491350
has_notable_trait = true;
13501351
}

0 commit comments

Comments
 (0)