Skip to content

Commit 9521da7

Browse files
authored
Rollup merge of #85970 - jsha:remove-methods-implementors, r=GuillaumeGomez
Remove methods under Implementors on trait pages As discussed at #84326 (comment). On a trait page, the "Implementors" section currently lists all methods of each implementor. That duplicates the method definitions on the trait itself, and is usually not very useful. So the implementors are collapsed by default. This PR changes rustdoc to just not render them at all. Any documentation specific to an implementor can be found by clicking through to the implementor's page. This moves the "portability" info inside the `<summary>` tags so it is still visible on trait pages (as originally implemented in #79201). That also means it will be visible on struct/enum pages when methods are collapsed. Add `#[doc(hidden)]` to all implementations of `Iterator::__iterator_get_unchecked` that didn't already have it. Otherwise, due to #86145, the structs/enums with those implementations would generate documentation for them, and that documentation would have a broken link into the Iterator page. Those links were already "broken" but not detected by the link-checker, because they pointed to one of the Implementors on the Iterator page, which happened to have the right anchor name. This reduces the Read trait's page size from 128kB to 68kB (uncompressed) and from 12,125 bytes to 9,989 bytes (gzipped Demo: https://hoffman-andrews.com/rust/remove-methods-implementors/std/string/struct.String.html#trait-implementations https://hoffman-andrews.com/rust/remove-methods-implementors/std/io/trait.Read.html#implementors r? `@GuillaumeGomez`
2 parents 31ee680 + bf81e13 commit 9521da7

26 files changed

+114
-153
lines changed

library/alloc/src/collections/vec_deque/into_iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl<T> Iterator for IntoIter<T> {
3838
}
3939

4040
#[inline]
41+
#[doc(hidden)]
4142
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
4243
where
4344
Self: TrustedRandomAccess,

library/alloc/src/collections/vec_deque/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
103103
}
104104

105105
#[inline]
106+
#[doc(hidden)]
106107
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
107108
where
108109
Self: TrustedRandomAccess,

library/alloc/src/collections/vec_deque/iter_mut.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
8989
}
9090

9191
#[inline]
92+
#[doc(hidden)]
9293
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
9394
where
9495
Self: TrustedRandomAccess,

library/alloc/src/vec/into_iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
163163
self.len()
164164
}
165165

166+
#[doc(hidden)]
166167
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> Self::Item
167168
where
168169
Self: TrustedRandomAccess,

library/core/src/array/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
132132
}
133133

134134
#[inline]
135+
#[doc(hidden)]
135136
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
136137
where
137138
Self: TrustedRandomAccess,

library/core/src/iter/adapters/cloned.rs

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ where
5858
self.it.map(T::clone).fold(init, f)
5959
}
6060

61+
#[doc(hidden)]
6162
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T
6263
where
6364
Self: TrustedRandomAccess,

library/core/src/iter/adapters/copied.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ where
7474
self.it.count()
7575
}
7676

77+
#[doc(hidden)]
7778
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> T
7879
where
7980
Self: TrustedRandomAccess,

library/core/src/iter/adapters/enumerate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ where
111111
}
112112

113113
#[rustc_inherit_overflow_checks]
114+
#[doc(hidden)]
114115
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <Self as Iterator>::Item
115116
where
116117
Self: TrustedRandomAccess,

library/core/src/iter/adapters/fuse.rs

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ where
114114
}
115115

116116
#[inline]
117+
#[doc(hidden)]
117118
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
118119
where
119120
Self: TrustedRandomAccess,

library/core/src/iter/adapters/map.rs

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ where
122122
self.iter.fold(init, map_fold(self.f, g))
123123
}
124124

125+
#[doc(hidden)]
125126
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> B
126127
where
127128
Self: TrustedRandomAccess,

library/core/src/iter/adapters/zip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ where
8888
}
8989

9090
#[inline]
91+
#[doc(hidden)]
9192
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
9293
where
9394
Self: TrustedRandomAccess,

library/core/src/iter/range.rs

+1
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ impl<A: Step> Iterator for ops::Range<A> {
667667
}
668668

669669
#[inline]
670+
#[doc(hidden)]
670671
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
671672
where
672673
Self: TrustedRandomAccess,

library/core/src/slice/iter.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunks<'a, T, N> {
21482148
self.iter.last()
21492149
}
21502150

2151+
#[doc(hidden)]
21512152
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a [T; N] {
21522153
// SAFETY: The safety guarantees of `__iterator_get_unchecked` are
21532154
// transferred to the caller.
@@ -2260,6 +2261,7 @@ impl<'a, T, const N: usize> Iterator for ArrayChunksMut<'a, T, N> {
22602261
self.iter.last()
22612262
}
22622263

2264+
#[doc(hidden)]
22632265
unsafe fn __iterator_get_unchecked(&mut self, i: usize) -> &'a mut [T; N] {
22642266
// SAFETY: The safety guarantees of `__iterator_get_unchecked` are transferred to
22652267
// the caller.

library/core/src/str/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl Iterator for Bytes<'_> {
295295
}
296296

297297
#[inline]
298+
#[doc(hidden)]
298299
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> u8 {
299300
// SAFETY: the caller must uphold the safety contract
300301
// for `Iterator::__iterator_get_unchecked`.

0 commit comments

Comments
 (0)