Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: notable traits triggers on smart pointers #100320

Closed
jsha opened this issue Aug 9, 2022 · 6 comments · Fixed by #103432
Closed

rustdoc: notable traits triggers on smart pointers #100320

jsha opened this issue Aug 9, 2022 · 6 comments · Fixed by #103432
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jsha
Copy link
Contributor

jsha commented Aug 9, 2022

The Pin and Box documentation shows "notable traits" on the new() method, and any other methods that return a Pin or a Box:

https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.new
https://doc.rust-lang.org/nightly/std/pin/struct.Pin.html#method.new

image

That's because these structs have "pass-through" implementations: if T implements Iterator, then Box<T> implements Iterator. If T implements Read, then Box<T> implements Read. Since new() returns Box<T>, it gets the ⓘ icon indicating a notable trait.

These return types should not be annotated with the ⓘ, since "notable traits" should be reserved for things that are actually notable - like the Iterator impl on std::slice::Iter.

One way to achieve this: if the where bounds for the impl include the "notable trait", don't consider that impl eligible for ⓘ treatment.

@jsha jsha added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Aug 9, 2022
@jsha
Copy link
Contributor Author

jsha commented Aug 10, 2022

Out of curiosity, I added a println! to emit a list of which types get the "notable traits" annotation for which traits. Running this over std, emitting one line per instance, and going through sort | uniq -c | sort -rn, I get the below. For instance, Zip shows up as a return type 183 times in the std docs, with a "notable trait" of iterator each time. The high count for iterator types is expected - it's because these get repeated on different pages for every item that implements Iterator.

After the iterator types, slice's Read/Write impls and Box's Read/Write/Future/Iterator impls are the most frequent.

    183 Some(DefId(1:46799 ~ core[e6fc]::iter::adapters::zip::Zip)) ---> Iterator
    182 Some(DefId(1:6892 ~ core[e6fc]::iter::adapters::intersperse::IntersperseWith)) ---> Iterator
    182 Some(DefId(1:6510 ~ core[e6fc]::iter::adapters::flatten::Flatten)) ---> Iterator
    182 Some(DefId(1:6437 ~ core[e6fc]::iter::adapters::flatten::FlatMap)) ---> Iterator
    182 Some(DefId(1:46789 ~ core[e6fc]::iter::adapters::take_while::TakeWhile)) ---> Iterator
    182 Some(DefId(1:46779 ~ core[e6fc]::iter::adapters::take::Take)) ---> Iterator
    182 Some(DefId(1:46768 ~ core[e6fc]::iter::adapters::step_by::StepBy)) ---> Iterator
    182 Some(DefId(1:46758 ~ core[e6fc]::iter::adapters::skip_while::SkipWhile)) ---> Iterator
    182 Some(DefId(1:46748 ~ core[e6fc]::iter::adapters::skip::Skip)) ---> Iterator
    182 Some(DefId(1:46736 ~ core[e6fc]::iter::adapters::scan::Scan)) ---> Iterator
    182 Some(DefId(1:46727 ~ core[e6fc]::iter::adapters::rev::Rev)) ---> Iterator
    182 Some(DefId(1:46717 ~ core[e6fc]::iter::adapters::peekable::Peekable)) ---> Iterator
    182 Some(DefId(1:46708 ~ core[e6fc]::iter::adapters::map_while::MapWhile)) ---> Iterator
    182 Some(DefId(1:46699 ~ core[e6fc]::iter::adapters::map::Map)) ---> Iterator
    182 Some(DefId(1:46688 ~ core[e6fc]::iter::adapters::intersperse::Intersperse)) ---> Iterator
    182 Some(DefId(1:46679 ~ core[e6fc]::iter::adapters::inspect::Inspect)) ---> Iterator
    182 Some(DefId(1:46670 ~ core[e6fc]::iter::adapters::fuse::Fuse)) ---> Iterator
    182 Some(DefId(1:46647 ~ core[e6fc]::iter::adapters::filter_map::FilterMap)) ---> Iterator
    182 Some(DefId(1:46638 ~ core[e6fc]::iter::adapters::filter::Filter)) ---> Iterator
    182 Some(DefId(1:46628 ~ core[e6fc]::iter::adapters::enumerate::Enumerate)) ---> Iterator
    182 Some(DefId(1:46618 ~ core[e6fc]::iter::adapters::cycle::Cycle)) ---> Iterator
    182 Some(DefId(1:46609 ~ core[e6fc]::iter::adapters::copied::Copied)) ---> Iterator
    182 Some(DefId(1:46600 ~ core[e6fc]::iter::adapters::cloned::Cloned)) ---> Iterator
    182 Some(DefId(1:46587 ~ core[e6fc]::iter::adapters::chain::Chain)) ---> Iterator
    162 Some(DefId(0:20037 ~ std[3c74]::prim_slice)) ---> Write
    162 Some(DefId(0:20037 ~ std[3c74]::prim_slice)) ---> Read
    149 Some(DefId(4:432 ~ alloc[7306]::boxed::Box)) ---> Write
    149 Some(DefId(4:432 ~ alloc[7306]::boxed::Box)) ---> Read
    149 Some(DefId(4:432 ~ alloc[7306]::boxed::Box)) ---> Iterator
    149 Some(DefId(4:432 ~ alloc[7306]::boxed::Box)) ---> Future
    103 Some(DefId(0:49186 ~ core[a4c8]::iter::adapters::zip::Zip)) ---> Iterator
    102 Some(DefId(0:49176 ~ core[a4c8]::iter::adapters::take_while::TakeWhile)) ---> Iterator
    102 Some(DefId(0:49166 ~ core[a4c8]::iter::adapters::take::Take)) ---> Iterator
    102 Some(DefId(0:49155 ~ core[a4c8]::iter::adapters::step_by::StepBy)) ---> Iterator
    102 Some(DefId(0:49145 ~ core[a4c8]::iter::adapters::skip_while::SkipWhile)) ---> Iterator
    102 Some(DefId(0:49135 ~ core[a4c8]::iter::adapters::skip::Skip)) ---> Iterator
    102 Some(DefId(0:49123 ~ core[a4c8]::iter::adapters::scan::Scan)) ---> Iterator
    102 Some(DefId(0:49114 ~ core[a4c8]::iter::adapters::rev::Rev)) ---> Iterator
    102 Some(DefId(0:49104 ~ core[a4c8]::iter::adapters::peekable::Peekable)) ---> Iterator
    102 Some(DefId(0:49095 ~ core[a4c8]::iter::adapters::map_while::MapWhile)) ---> Iterator
    102 Some(DefId(0:49086 ~ core[a4c8]::iter::adapters::map::Map)) ---> Iterator
    102 Some(DefId(0:49075 ~ core[a4c8]::iter::adapters::intersperse::Intersperse)) ---> Iterator
    102 Some(DefId(0:49066 ~ core[a4c8]::iter::adapters::inspect::Inspect)) ---> Iterator
    102 Some(DefId(0:49057 ~ core[a4c8]::iter::adapters::fuse::Fuse)) ---> Iterator
    102 Some(DefId(0:49034 ~ core[a4c8]::iter::adapters::filter_map::FilterMap)) ---> Iterator
    102 Some(DefId(0:49025 ~ core[a4c8]::iter::adapters::filter::Filter)) ---> Iterator
    102 Some(DefId(0:49015 ~ core[a4c8]::iter::adapters::enumerate::Enumerate)) ---> Iterator
    102 Some(DefId(0:49005 ~ core[a4c8]::iter::adapters::cycle::Cycle)) ---> Iterator
    102 Some(DefId(0:48996 ~ core[a4c8]::iter::adapters::copied::Copied)) ---> Iterator
    102 Some(DefId(0:48987 ~ core[a4c8]::iter::adapters::cloned::Cloned)) ---> Iterator
    102 Some(DefId(0:48974 ~ core[a4c8]::iter::adapters::chain::Chain)) ---> Iterator
    101 Some(DefId(0:6892 ~ core[a4c8]::iter::adapters::intersperse::IntersperseWith)) ---> Iterator
    101 Some(DefId(0:6510 ~ core[a4c8]::iter::adapters::flatten::Flatten)) ---> Iterator
    101 Some(DefId(0:6437 ~ core[a4c8]::iter::adapters::flatten::FlatMap)) ---> Iterator
     81 Some(DefId(4:7780 ~ alloc[7306]::vec::Vec)) ---> Write
     34 Some(DefId(0:432 ~ alloc[1cec]::boxed::Box)) ---> Iterator
     34 Some(DefId(0:432 ~ alloc[1cec]::boxed::Box)) ---> Future
     26 Some(DefId(1:47611 ~ core[e6fc]::pin::Pin)) ---> Future
     22 Some(DefId(4:4628 ~ alloc[7306]::collections::vec_deque::VecDeque)) ---> Write
     22 Some(DefId(4:4628 ~ alloc[7306]::collections::vec_deque::VecDeque)) ---> Read
     22 Some(DefId(0:12063 ~ std[3c74]::io::Bytes)) ---> Iterator
     22 Some(DefId(0:12056 ~ std[3c74]::io::Take)) ---> Read
     22 Some(DefId(0:12046 ~ std[3c74]::io::Chain)) ---> Read
     18 Some(DefId(0:49998 ~ core[a4c8]::pin::Pin)) ---> Future
     14 Some(DefId(1:45873 ~ core[e6fc]::ops::range::Range)) ---> Iterator
     11 Some(DefId(1:11113 ~ core[e6fc]::slice::iter::Iter)) ---> Iterator
     11 Some(DefId(0:12076 ~ std[3c74]::io::Lines)) ---> Iterator
     10 Some(DefId(0:12069 ~ std[3c74]::io::Split)) ---> Iterator
     10 Some(DefId(0:11808 ~ std[3c74]::io::cursor::Cursor)) ---> Write
      8 Some(DefId(1:11137 ~ core[e6fc]::slice::iter::IterMut)) ---> Iterator
      7 Some(DefId(4:4443 ~ alloc[7306]::collections::vec_deque::iter::Iter)) ---> Iterator
      7 Some(DefId(1:49368 ~ core[e6fc]::slice::iter::RChunksExact)) ---> Iterator
      7 Some(DefId(1:49349 ~ core[e6fc]::slice::iter::RChunks)) ---> Iterator
      7 Some(DefId(1:49323 ~ core[e6fc]::slice::iter::ArrayChunks)) ---> Iterator
      7 Some(DefId(1:49297 ~ core[e6fc]::slice::iter::ArrayWindows)) ---> Iterator
      7 Some(DefId(1:49276 ~ core[e6fc]::slice::iter::ChunksExact)) ---> Iterator
      7 Some(DefId(1:49257 ~ core[e6fc]::slice::iter::Chunks)) ---> Iterator
      7 Some(DefId(1:49248 ~ core[e6fc]::slice::iter::Windows)) ---> Iterator
      7 Some(DefId(1:49043 ~ core[e6fc]::slice::ascii::EscapeAscii)) ---> Iterator
      7 Some(DefId(1:11317 ~ core[e6fc]::slice::iter::RSplit)) ---> Iterator
      7 Some(DefId(1:11205 ~ core[e6fc]::slice::iter::SplitInclusive)) ---> Iterator
      7 Some(DefId(1:11162 ~ core[e6fc]::slice::iter::Split)) ---> Iterator
      6 Some(DefId(4:4306 ~ alloc[7306]::collections::vec_deque::iter_mut::IterMut)) ---> Iterator
      6 Some(DefId(1:45942 ~ core[e6fc]::ops::range::RangeInclusive)) ---> Iterator
      6 Some(DefId(0:12003 ~ std[3c74]::io::util::Sink)) ---> Write
      5 Some(DefId(4:3759 ~ alloc[7306]::collections::linked_list::Iter)) ---> Iterator
      5 Some(DefId(4:3329 ~ alloc[7306]::collections::btree::set::Iter)) ---> Iterator
      5 Some(DefId(4:1597 ~ alloc[7306]::collections::btree::map::Iter)) ---> Iterator
      5 Some(DefId(4:1011 ~ alloc[7306]::collections::binary_heap::Iter)) ---> Iterator
      5 Some(DefId(1:49776 ~ core[e6fc]::str::iter::EscapeUnicode)) ---> Iterator
      5 Some(DefId(1:49767 ~ core[e6fc]::str::iter::EscapeDefault)) ---> Iterator
      5 Some(DefId(1:49758 ~ core[e6fc]::str::iter::EscapeDebug)) ---> Iterator
      5 Some(DefId(1:49751 ~ core[e6fc]::str::iter::EncodeUtf16)) ---> Iterator
      5 Some(DefId(1:49742 ~ core[e6fc]::str::iter::SplitAsciiWhitespace)) ---> Iterator
      5 Some(DefId(1:49733 ~ core[e6fc]::str::iter::SplitWhitespace)) ---> Iterator
      5 Some(DefId(1:49723 ~ core[e6fc]::str::iter::LinesAny)) ---> Iterator
      5 Some(DefId(1:49713 ~ core[e6fc]::str::iter::Lines)) ---> Iterator
      5 Some(DefId(1:49681 ~ core[e6fc]::str::iter::RMatches)) ---> Iterator
      5 Some(DefId(1:49663 ~ core[e6fc]::str::iter::Matches)) ---> Iterator
      5 Some(DefId(1:49627 ~ core[e6fc]::str::iter::RMatchIndices)) ---> Iterator
      5 Some(DefId(1:49609 ~ core[e6fc]::str::iter::MatchIndices)) ---> Iterator
      5 Some(DefId(1:49581 ~ core[e6fc]::str::iter::RSplitN)) ---> Iterator
      5 Some(DefId(1:49563 ~ core[e6fc]::str::iter::SplitN)) ---> Iterator
      5 Some(DefId(1:49527 ~ core[e6fc]::str::iter::RSplitTerminator)) ---> Iterator
      5 Some(DefId(1:49509 ~ core[e6fc]::str::iter::SplitTerminator)) ---> Iterator
      5 Some(DefId(1:49477 ~ core[e6fc]::str::iter::RSplit)) ---> Iterator
      5 Some(DefId(1:49459 ~ core[e6fc]::str::iter::Split)) ---> Iterator
      5 Some(DefId(1:49445 ~ core[e6fc]::str::iter::Bytes)) ---> Iterator
      5 Some(DefId(1:49435 ~ core[e6fc]::str::iter::CharIndices)) ---> Iterator
      5 Some(DefId(1:49429 ~ core[e6fc]::str::iter::Chars)) ---> Iterator
      5 Some(DefId(1:45898 ~ core[e6fc]::ops::range::RangeFrom)) ---> Iterator
      5 Some(DefId(1:12845 ~ core[e6fc]::str::iter::SplitInclusive)) ---> Iterator
      5 Some(DefId(1:11923 ~ core[e6fc]::slice::iter::GroupBy)) ---> Iterator
      5 Some(DefId(1:11410 ~ core[e6fc]::slice::iter::RSplitN)) ---> Iterator
      5 Some(DefId(1:11396 ~ core[e6fc]::slice::iter::SplitN)) ---> Iterator
      5 Some(DefId(0:48260 ~ core[a4c8]::ops::range::Range)) ---> Iterator
      5 Some(DefId(0:12654 ~ std[3c74]::path::Iter)) ---> Iterator
      4 Some(DefId(4:3772 ~ alloc[7306]::collections::linked_list::IterMut)) ---> Iterator
      4 Some(DefId(4:1607 ~ alloc[7306]::collections::btree::map::IterMut)) ---> Iterator
      4 Some(DefId(1:49378 ~ core[e6fc]::slice::iter::RChunksExactMut)) ---> Iterator
      4 Some(DefId(1:49358 ~ core[e6fc]::slice::iter::RChunksMut)) ---> Iterator
      4 Some(DefId(1:49336 ~ core[e6fc]::slice::iter::ArrayChunksMut)) ---> Iterator
      4 Some(DefId(1:49286 ~ core[e6fc]::slice::iter::ChunksExactMut)) ---> Iterator
      4 Some(DefId(1:49266 ~ core[e6fc]::slice::iter::ChunksMut)) ---> Iterator
      4 Some(DefId(1:48133 ~ core[e6fc]::sync::exclusive::Exclusive)) ---> Future
      4 Some(DefId(1:4377 ~ core[e6fc]::array::iter::IntoIter)) ---> Iterator
      4 Some(DefId(1:11956 ~ core[e6fc]::slice::iter::GroupByMut)) ---> Iterator
      4 Some(DefId(1:11438 ~ core[e6fc]::slice::iter::RSplitNMut)) ---> Iterator
      4 Some(DefId(1:11424 ~ core[e6fc]::slice::iter::SplitNMut)) ---> Iterator
      4 Some(DefId(1:11355 ~ core[e6fc]::slice::iter::RSplitMut)) ---> Iterator
      4 Some(DefId(1:11282 ~ core[e6fc]::slice::iter::SplitInclusiveMut)) ---> Iterator
      4 Some(DefId(1:11244 ~ core[e6fc]::slice::iter::SplitMut)) ---> Iterator
      4 Some(DefId(0:5377 ~ std[3c74]::net::tcp::TcpStream)) ---> Write
      4 Some(DefId(0:5377 ~ std[3c74]::net::tcp::TcpStream)) ---> Read
      4 Some(DefId(0:3196 ~ std[3c74]::fs::File)) ---> Write
      4 Some(DefId(0:3196 ~ std[3c74]::fs::File)) ---> Read
      4 Some(DefId(0:2159 ~ std[3c74]::collections::hash::set::Iter)) ---> Iterator
      4 Some(DefId(0:19260 ~ std[3c74]::sys_common::wtf8::EncodeWide)) ---> Iterator
      4 Some(DefId(0:1432 ~ std[3c74]::collections::hash::map::IterMut)) ---> Iterator
      4 Some(DefId(0:1419 ~ std[3c74]::collections::hash::map::Iter)) ---> Iterator
      3 Some(DefId(4:8203 ~ alloc[7306]::collections::vec_deque::into_iter::IntoIter)) ---> Iterator
      3 Some(DefId(4:8197 ~ alloc[7306]::collections::linked_list::IntoIter)) ---> Iterator
      3 Some(DefId(4:8168 ~ alloc[7306]::collections::btree::set::Range)) ---> Iterator
      3 Some(DefId(4:8121 ~ alloc[7306]::collections::binary_heap::IntoIterSorted)) ---> Iterator
      3 Some(DefId(4:8115 ~ alloc[7306]::collections::binary_heap::IntoIter)) ---> Iterator
      3 Some(DefId(4:3396 ~ alloc[7306]::collections::btree::set::Union)) ---> Iterator
      3 Some(DefId(4:3370 ~ alloc[7306]::collections::btree::set::Intersection)) ---> Iterator
      3 Some(DefId(4:3362 ~ alloc[7306]::collections::btree::set::SymmetricDifference)) ---> Iterator
      3 Some(DefId(4:3336 ~ alloc[7306]::collections::btree::set::Difference)) ---> Iterator
      3 Some(DefId(4:1685 ~ alloc[7306]::collections::btree::map::Range)) ---> Iterator
      3 Some(DefId(4:1644 ~ alloc[7306]::collections::btree::map::Values)) ---> Iterator
      3 Some(DefId(4:1635 ~ alloc[7306]::collections::btree::map::Keys)) ---> Iterator
      3 Some(DefId(1:8106 ~ core[e6fc]::iter::sources::empty::Empty)) ---> Iterator
      3 Some(DefId(1:47663 ~ core[e6fc]::result::Iter)) ---> Iterator
      3 Some(DefId(1:47534 ~ core[e6fc]::option::Iter)) ---> Iterator
      3 Some(DefId(1:46340 ~ core[e6fc]::char::decode::DecodeUtf16)) ---> Iterator
      3 Some(DefId(1:46281 ~ core[e6fc]::ascii::EscapeDefault)) ---> Iterator
      3 Some(DefId(0:8106 ~ core[a4c8]::iter::sources::empty::Empty)) ---> Iterator
      3 Some(DefId(0:48727 ~ core[a4c8]::char::decode::DecodeUtf16)) ---> Iterator
      3 Some(DefId(0:48668 ~ core[a4c8]::ascii::EscapeDefault)) ---> Iterator
      3 Some(DefId(0:4443 ~ alloc[1cec]::collections::vec_deque::iter::Iter)) ---> Iterator
      3 Some(DefId(0:4306 ~ alloc[1cec]::collections::vec_deque::iter_mut::IterMut)) ---> Iterator
      3 Some(DefId(0:12660 ~ std[3c74]::path::Ancestors)) ---> Iterator
      3 Some(DefId(0:12644 ~ std[3c74]::path::Components)) ---> Iterator
      3 Some(DefId(0:11996 ~ std[3c74]::io::util::Empty)) ---> Read
      3 Some(DefId(0:11137 ~ core[a4c8]::slice::iter::IterMut)) ---> Iterator
      3 Some(DefId(0:11113 ~ core[a4c8]::slice::iter::Iter)) ---> Iterator
      2 Some(DefId(4:8160 ~ alloc[7306]::collections::btree::set::IntoIter)) ---> Iterator
      2 Some(DefId(4:8138 ~ alloc[7306]::collections::binary_heap::DrainSorted)) ---> Iterator
      2 Some(DefId(4:8130 ~ alloc[7306]::collections::binary_heap::Drain)) ---> Iterator
      2 Some(DefId(4:7379 ~ alloc[7306]::vec::into_iter::IntoIter)) ---> Iterator
      2 Some(DefId(4:4215 ~ alloc[7306]::collections::vec_deque::drain::Drain)) ---> Iterator
      2 Some(DefId(4:3951 ~ alloc[7306]::collections::linked_list::DrainFilter)) ---> Iterator
      2 Some(DefId(4:3488 ~ alloc[7306]::collections::btree::set::DrainFilter)) ---> Iterator
      2 Some(DefId(4:1939 ~ alloc[7306]::collections::btree::map::DrainFilter)) ---> Iterator
      2 Some(DefId(4:1694 ~ alloc[7306]::collections::btree::map::RangeMut)) ---> Iterator
      2 Some(DefId(4:1674 ~ alloc[7306]::collections::btree::map::IntoValues)) ---> Iterator
      2 Some(DefId(4:1663 ~ alloc[7306]::collections::btree::map::IntoKeys)) ---> Iterator
      2 Some(DefId(4:1653 ~ alloc[7306]::collections::btree::map::ValuesMut)) ---> Iterator
      2 Some(DefId(4:1618 ~ alloc[7306]::collections::btree::map::IntoIter)) ---> Iterator
      2 Some(DefId(1:50341 ~ core[e6fc]::future::ready::Ready)) ---> Future
      2 Some(DefId(1:47679 ~ core[e6fc]::result::IntoIter)) ---> Iterator
      2 Some(DefId(1:47671 ~ core[e6fc]::result::IterMut)) ---> Iterator
      2 Some(DefId(1:47550 ~ core[e6fc]::option::IntoIter)) ---> Iterator
      2 Some(DefId(1:47542 ~ core[e6fc]::option::IterMut)) ---> Iterator
      2 Some(DefId(1:47015 ~ core[e6fc]::iter::sources::successors::Successors)) ---> Iterator
      2 Some(DefId(1:47004 ~ core[e6fc]::iter::sources::repeat_with::RepeatWith)) ---> Iterator
      2 Some(DefId(1:46995 ~ core[e6fc]::iter::sources::repeat::Repeat)) ---> Iterator
      2 Some(DefId(1:46986 ~ core[e6fc]::iter::sources::once_with::OnceWith)) ---> Iterator
      2 Some(DefId(1:46977 ~ core[e6fc]::iter::sources::once::Once)) ---> Iterator
      2 Some(DefId(1:46970 ~ core[e6fc]::iter::sources::from_fn::FromFn)) ---> Iterator
      2 Some(DefId(1:46424 ~ core[e6fc]::char::ToUppercase)) ---> Iterator
      2 Some(DefId(1:46417 ~ core[e6fc]::char::ToLowercase)) ---> Iterator
      2 Some(DefId(1:46410 ~ core[e6fc]::char::EscapeDebug)) ---> Iterator
      2 Some(DefId(1:46388 ~ core[e6fc]::char::EscapeDefault)) ---> Iterator
      2 Some(DefId(1:46363 ~ core[e6fc]::char::EscapeUnicode)) ---> Iterator
      2 Some(DefId(1:13857 ~ core[e6fc]::future::pending::Pending)) ---> Future
      2 Some(DefId(0:8203 ~ alloc[1cec]::collections::vec_deque::into_iter::IntoIter)) ---> Iterator
      2 Some(DefId(0:8197 ~ alloc[1cec]::collections::linked_list::IntoIter)) ---> Iterator
      2 Some(DefId(0:8121 ~ alloc[1cec]::collections::binary_heap::IntoIterSorted)) ---> Iterator
      2 Some(DefId(0:8115 ~ alloc[1cec]::collections::binary_heap::IntoIter)) ---> Iterator
      2 Some(DefId(0:6324 ~ std[3c74]::os::unix::net::stream::UnixStream)) ---> Write
      2 Some(DefId(0:6324 ~ std[3c74]::os::unix::net::stream::UnixStream)) ---> Read
      2 Some(DefId(0:52728 ~ core[a4c8]::future::ready::Ready)) ---> Future
      2 Some(DefId(0:52163 ~ core[a4c8]::str::iter::EscapeUnicode)) ---> Iterator
      2 Some(DefId(0:52154 ~ core[a4c8]::str::iter::EscapeDefault)) ---> Iterator
      2 Some(DefId(0:52145 ~ core[a4c8]::str::iter::EscapeDebug)) ---> Iterator
      2 Some(DefId(0:52138 ~ core[a4c8]::str::iter::EncodeUtf16)) ---> Iterator
      2 Some(DefId(0:52129 ~ core[a4c8]::str::iter::SplitAsciiWhitespace)) ---> Iterator
      2 Some(DefId(0:52120 ~ core[a4c8]::str::iter::SplitWhitespace)) ---> Iterator
      2 Some(DefId(0:52110 ~ core[a4c8]::str::iter::LinesAny)) ---> Iterator
      2 Some(DefId(0:52100 ~ core[a4c8]::str::iter::Lines)) ---> Iterator
      2 Some(DefId(0:51832 ~ core[a4c8]::str::iter::Bytes)) ---> Iterator
      2 Some(DefId(0:51822 ~ core[a4c8]::str::iter::CharIndices)) ---> Iterator
      2 Some(DefId(0:51816 ~ core[a4c8]::str::iter::Chars)) ---> Iterator
      2 Some(DefId(0:51755 ~ core[a4c8]::slice::iter::RChunksExact)) ---> Iterator
      2 Some(DefId(0:51684 ~ core[a4c8]::slice::iter::ArrayWindows)) ---> Iterator
      2 Some(DefId(0:51430 ~ core[a4c8]::slice::ascii::EscapeAscii)) ---> Iterator
      2 Some(DefId(0:50520 ~ core[a4c8]::sync::exclusive::Exclusive)) ---> Future
      2 Some(DefId(0:50066 ~ core[a4c8]::result::IntoIter)) ---> Iterator
      2 Some(DefId(0:50058 ~ core[a4c8]::result::IterMut)) ---> Iterator
      2 Some(DefId(0:50050 ~ core[a4c8]::result::Iter)) ---> Iterator
      2 Some(DefId(0:49937 ~ core[a4c8]::option::IntoIter)) ---> Iterator
      2 Some(DefId(0:49929 ~ core[a4c8]::option::IterMut)) ---> Iterator
      2 Some(DefId(0:49921 ~ core[a4c8]::option::Iter)) ---> Iterator
      2 Some(DefId(0:49402 ~ core[a4c8]::iter::sources::successors::Successors)) ---> Iterator
      2 Some(DefId(0:49391 ~ core[a4c8]::iter::sources::repeat_with::RepeatWith)) ---> Iterator
      2 Some(DefId(0:49382 ~ core[a4c8]::iter::sources::repeat::Repeat)) ---> Iterator
      2 Some(DefId(0:49373 ~ core[a4c8]::iter::sources::once_with::OnceWith)) ---> Iterator
      2 Some(DefId(0:49364 ~ core[a4c8]::iter::sources::once::Once)) ---> Iterator
      2 Some(DefId(0:49357 ~ core[a4c8]::iter::sources::from_fn::FromFn)) ---> Iterator
      2 Some(DefId(0:48811 ~ core[a4c8]::char::ToUppercase)) ---> Iterator
      2 Some(DefId(0:48804 ~ core[a4c8]::char::ToLowercase)) ---> Iterator
      2 Some(DefId(0:48797 ~ core[a4c8]::char::EscapeDebug)) ---> Iterator
      2 Some(DefId(0:48775 ~ core[a4c8]::char::EscapeDefault)) ---> Iterator
      2 Some(DefId(0:48750 ~ core[a4c8]::char::EscapeUnicode)) ---> Iterator
      2 Some(DefId(0:4514 ~ std[3c74]::io::stdio::Stderr)) ---> Write
      2 Some(DefId(0:4475 ~ std[3c74]::io::stdio::Stdout)) ---> Write
      2 Some(DefId(0:3772 ~ alloc[1cec]::collections::linked_list::IterMut)) ---> Iterator
      2 Some(DefId(0:3759 ~ alloc[1cec]::collections::linked_list::Iter)) ---> Iterator
      2 Some(DefId(0:3740 ~ std[3c74]::io::buffered::linewriter::LineWriter)) ---> Write
      2 Some(DefId(0:3652 ~ std[3c74]::io::buffered::bufwriter::BufWriter)) ---> Write
      2 Some(DefId(0:3565 ~ std[3c74]::io::buffered::bufreader::BufReader)) ---> Read
      2 Some(DefId(0:3329 ~ alloc[1cec]::collections::btree::set::Iter)) ---> Iterator
      2 Some(DefId(0:3015 ~ proc_macro[1644]::token_stream::IntoIter)) ---> Iterator
      2 Some(DefId(0:2192 ~ std[3c74]::collections::hash::set::Union)) ---> Iterator
      2 Some(DefId(0:2187 ~ std[3c74]::collections::hash::set::SymmetricDifference)) ---> Iterator
      2 Some(DefId(0:2181 ~ std[3c74]::collections::hash::set::Difference)) ---> Iterator
      2 Some(DefId(0:2175 ~ std[3c74]::collections::hash::set::Intersection)) ---> Iterator
      2 Some(DefId(0:2170 ~ std[3c74]::collections::hash::set::DrainFilter)) ---> Iterator
      2 Some(DefId(0:2166 ~ std[3c74]::collections::hash::set::Drain)) ---> Iterator
      2 Some(DefId(0:2163 ~ std[3c74]::collections::hash::set::IntoIter)) ---> Iterator
      2 Some(DefId(0:1607 ~ alloc[1cec]::collections::btree::map::IterMut)) ---> Iterator
      2 Some(DefId(0:1597 ~ alloc[1cec]::collections::btree::map::Iter)) ---> Iterator
      2 Some(DefId(0:1501 ~ std[3c74]::collections::hash::map::IntoValues)) ---> Iterator
      2 Some(DefId(0:1497 ~ std[3c74]::collections::hash::map::IntoKeys)) ---> Iterator
      2 Some(DefId(0:1492 ~ std[3c74]::collections::hash::map::ValuesMut)) ---> Iterator
      2 Some(DefId(0:1486 ~ std[3c74]::collections::hash::map::DrainFilter)) ---> Iterator
      2 Some(DefId(0:1476 ~ std[3c74]::collections::hash::map::Drain)) ---> Iterator
      2 Some(DefId(0:1463 ~ std[3c74]::collections::hash::map::Values)) ---> Iterator
      2 Some(DefId(0:1450 ~ std[3c74]::collections::hash::map::Keys)) ---> Iterator
      2 Some(DefId(0:1442 ~ std[3c74]::collections::hash::map::IntoIter)) ---> Iterator
      2 Some(DefId(0:13102 ~ std[3c74]::sync::mpsc::Iter)) ---> Iterator
      2 Some(DefId(0:12354 ~ std[3c74]::os::unix::net::listener::Incoming)) ---> Iterator
      2 Some(DefId(0:11808 ~ std[3c74]::io::cursor::Cursor)) ---> Read
      2 Some(DefId(0:11636 ~ std[3c74]::error::Chain)) ---> Iterator
      2 Some(DefId(0:1011 ~ alloc[1cec]::collections::binary_heap::Iter)) ---> Iterator
      1 Some(DefId(4:8463 ~ alloc[7306]::vec::splice::Splice)) ---> Iterator
      1 Some(DefId(4:8446 ~ alloc[7306]::vec::drain_filter::DrainFilter)) ---> Iterator
      1 Some(DefId(4:7212 ~ alloc[7306]::vec::drain::Drain)) ---> Iterator
      1 Some(DefId(4:6475 ~ alloc[7306]::string::Drain)) ---> Iterator
      1 Some(DefId(1:9260 ~ core[e6fc]::panic::unwind_safe::AssertUnwindSafe)) ---> Future
      1 Some(DefId(1:13892 ~ core[e6fc]::future::poll_fn::PollFn)) ---> Future
      1 Some(DefId(0:8463 ~ alloc[1cec]::vec::splice::Splice)) ---> Iterator
      1 Some(DefId(0:8446 ~ alloc[1cec]::vec::drain_filter::DrainFilter)) ---> Iterator
      1 Some(DefId(0:8168 ~ alloc[1cec]::collections::btree::set::Range)) ---> Iterator
      1 Some(DefId(0:8160 ~ alloc[1cec]::collections::btree::set::IntoIter)) ---> Iterator
      1 Some(DefId(0:8138 ~ alloc[1cec]::collections::binary_heap::DrainSorted)) ---> Iterator
      1 Some(DefId(0:8130 ~ alloc[1cec]::collections::binary_heap::Drain)) ---> Iterator
      1 Some(DefId(0:7379 ~ alloc[1cec]::vec::into_iter::IntoIter)) ---> Iterator
      1 Some(DefId(0:7212 ~ alloc[1cec]::vec::drain::Drain)) ---> Iterator
      1 Some(DefId(0:6475 ~ alloc[1cec]::string::Drain)) ---> Iterator
      1 Some(DefId(0:5986 ~ std[3c74]::os::unix::net::ancillary::Messages)) ---> Iterator
      1 Some(DefId(0:52068 ~ core[a4c8]::str::iter::RMatches)) ---> Iterator
      1 Some(DefId(0:52050 ~ core[a4c8]::str::iter::Matches)) ---> Iterator
      1 Some(DefId(0:52014 ~ core[a4c8]::str::iter::RMatchIndices)) ---> Iterator
      1 Some(DefId(0:51996 ~ core[a4c8]::str::iter::MatchIndices)) ---> Iterator
      1 Some(DefId(0:51968 ~ core[a4c8]::str::iter::RSplitN)) ---> Iterator
      1 Some(DefId(0:51950 ~ core[a4c8]::str::iter::SplitN)) ---> Iterator
      1 Some(DefId(0:51914 ~ core[a4c8]::str::iter::RSplitTerminator)) ---> Iterator
      1 Some(DefId(0:51896 ~ core[a4c8]::str::iter::SplitTerminator)) ---> Iterator
      1 Some(DefId(0:51864 ~ core[a4c8]::str::iter::RSplit)) ---> Iterator
      1 Some(DefId(0:51846 ~ core[a4c8]::str::iter::Split)) ---> Iterator
      1 Some(DefId(0:51765 ~ core[a4c8]::slice::iter::RChunksExactMut)) ---> Iterator
      1 Some(DefId(0:51745 ~ core[a4c8]::slice::iter::RChunksMut)) ---> Iterator
      1 Some(DefId(0:51736 ~ core[a4c8]::slice::iter::RChunks)) ---> Iterator
      1 Some(DefId(0:51723 ~ core[a4c8]::slice::iter::ArrayChunksMut)) ---> Iterator
      1 Some(DefId(0:51710 ~ core[a4c8]::slice::iter::ArrayChunks)) ---> Iterator
      1 Some(DefId(0:51673 ~ core[a4c8]::slice::iter::ChunksExactMut)) ---> Iterator
      1 Some(DefId(0:51663 ~ core[a4c8]::slice::iter::ChunksExact)) ---> Iterator
      1 Some(DefId(0:51653 ~ core[a4c8]::slice::iter::ChunksMut)) ---> Iterator
      1 Some(DefId(0:51644 ~ core[a4c8]::slice::iter::Chunks)) ---> Iterator
      1 Some(DefId(0:51635 ~ core[a4c8]::slice::iter::Windows)) ---> Iterator
      1 Some(DefId(0:48329 ~ core[a4c8]::ops::range::RangeInclusive)) ---> Iterator
      1 Some(DefId(0:48285 ~ core[a4c8]::ops::range::RangeFrom)) ---> Iterator
      1 Some(DefId(0:4611 ~ std[3c74]::io::util::Repeat)) ---> Read
      1 Some(DefId(0:4516 ~ std[3c74]::io::stdio::StderrLock)) ---> Write
      1 Some(DefId(0:4477 ~ std[3c74]::io::stdio::StdoutLock)) ---> Write
      1 Some(DefId(0:4438 ~ std[3c74]::io::stdio::StdinLock)) ---> Read
      1 Some(DefId(0:4436 ~ std[3c74]::io::stdio::Stdin)) ---> Read
      1 Some(DefId(0:4215 ~ alloc[1cec]::collections::vec_deque::drain::Drain)) ---> Iterator
      1 Some(DefId(0:3951 ~ alloc[1cec]::collections::linked_list::DrainFilter)) ---> Iterator
      1 Some(DefId(0:3488 ~ alloc[1cec]::collections::btree::set::DrainFilter)) ---> Iterator
      1 Some(DefId(0:3396 ~ alloc[1cec]::collections::btree::set::Union)) ---> Iterator
      1 Some(DefId(0:3370 ~ alloc[1cec]::collections::btree::set::Intersection)) ---> Iterator
      1 Some(DefId(0:3362 ~ alloc[1cec]::collections::btree::set::SymmetricDifference)) ---> Iterator
      1 Some(DefId(0:3336 ~ alloc[1cec]::collections::btree::set::Difference)) ---> Iterator
      1 Some(DefId(0:2462 ~ std[3c74]::env::ArgsOs)) ---> Iterator
      1 Some(DefId(0:2460 ~ std[3c74]::env::Args)) ---> Iterator
      1 Some(DefId(0:2437 ~ std[3c74]::env::SplitPaths)) ---> Iterator
      1 Some(DefId(0:2401 ~ std[3c74]::env::VarsOs)) ---> Iterator
      1 Some(DefId(0:2399 ~ std[3c74]::env::Vars)) ---> Iterator
      1 Some(DefId(0:1939 ~ alloc[1cec]::collections::btree::map::DrainFilter)) ---> Iterator
      1 Some(DefId(0:19155 ~ std[3c74]::sys_common::process::CommandEnvs)) ---> Iterator
      1 Some(DefId(0:1694 ~ alloc[1cec]::collections::btree::map::RangeMut)) ---> Iterator
      1 Some(DefId(0:1685 ~ alloc[1cec]::collections::btree::map::Range)) ---> Iterator
      1 Some(DefId(0:1674 ~ alloc[1cec]::collections::btree::map::IntoValues)) ---> Iterator
      1 Some(DefId(0:1663 ~ alloc[1cec]::collections::btree::map::IntoKeys)) ---> Iterator
      1 Some(DefId(0:1653 ~ alloc[1cec]::collections::btree::map::ValuesMut)) ---> Iterator
      1 Some(DefId(0:1644 ~ alloc[1cec]::collections::btree::map::Values)) ---> Iterator
      1 Some(DefId(0:1635 ~ alloc[1cec]::collections::btree::map::Keys)) ---> Iterator
      1 Some(DefId(0:1618 ~ alloc[1cec]::collections::btree::map::IntoIter)) ---> Iterator
      1 Some(DefId(0:13892 ~ core[a4c8]::future::poll_fn::PollFn)) ---> Future
      1 Some(DefId(0:13857 ~ core[a4c8]::future::pending::Pending)) ---> Future
      1 Some(DefId(0:13283 ~ core[a4c8]::str::lossy::Utf8LossyChunksIter)) ---> Iterator
      1 Some(DefId(0:13118 ~ std[3c74]::sync::mpsc::IntoIter)) ---> Iterator
      1 Some(DefId(0:13110 ~ std[3c74]::sync::mpsc::TryIter)) ---> Iterator
      1 Some(DefId(0:12990 ~ std[3c74]::process::CommandArgs)) ---> Iterator
      1 Some(DefId(0:12845 ~ core[a4c8]::str::iter::SplitInclusive)) ---> Iterator
      1 Some(DefId(0:12286 ~ std[3c74]::net::tcp::IntoIncoming)) ---> Iterator
      1 Some(DefId(0:12280 ~ std[3c74]::net::tcp::Incoming)) ---> Iterator
      1 Some(DefId(0:11956 ~ core[a4c8]::slice::iter::GroupByMut)) ---> Iterator
      1 Some(DefId(0:11923 ~ core[a4c8]::slice::iter::GroupBy)) ---> Iterator
      1 Some(DefId(0:11438 ~ core[a4c8]::slice::iter::RSplitNMut)) ---> Iterator
      1 Some(DefId(0:11424 ~ core[a4c8]::slice::iter::SplitNMut)) ---> Iterator
      1 Some(DefId(0:11410 ~ core[a4c8]::slice::iter::RSplitN)) ---> Iterator
      1 Some(DefId(0:11396 ~ core[a4c8]::slice::iter::SplitN)) ---> Iterator
      1 Some(DefId(0:11355 ~ core[a4c8]::slice::iter::RSplitMut)) ---> Iterator
      1 Some(DefId(0:11317 ~ core[a4c8]::slice::iter::RSplit)) ---> Iterator
      1 Some(DefId(0:11282 ~ core[a4c8]::slice::iter::SplitInclusiveMut)) ---> Iterator
      1 Some(DefId(0:11244 ~ core[a4c8]::slice::iter::SplitMut)) ---> Iterator
      1 Some(DefId(0:11205 ~ core[a4c8]::slice::iter::SplitInclusive)) ---> Iterator
      1 Some(DefId(0:11162 ~ core[a4c8]::slice::iter::Split)) ---> Iterator

@compiler-errors
Copy link
Member

compiler-errors commented Aug 12, 2022

One way to achieve this: if the where bounds for the impl include the "notable trait", don't consider that impl eligible for ⓘ treatment.

I got a PR implementing this solution, just need to clean it up. @jsha: What's the best way to make a test for this? Just a regular rustdoc test?

@compiler-errors compiler-errors self-assigned this Aug 12, 2022
@jsha
Copy link
Contributor Author

jsha commented Aug 12, 2022

What's the best way to make a test for this? Just a regular rustdoc test?

Yep! Specifically one of the tests under src/test/rustdoc that generates documentation for a small example and then makes assertions on the output.

Note that this is a bit of a tricky test since it's a negative assertion. So it would be easy for the test to pass but for unrelated reasons (for instance if we changed the HTML layout). To avoid that problem I recommend having two parts of the test, for two different items: one item that should have the annotation, and one item that should not have the annotation. That way if the HTML layout changes the test will fail.

@jsha
Copy link
Contributor Author

jsha commented Aug 30, 2022

@compiler-errors any updates? BTW I think it would be reasonable to just special case "Box" and "Pin" by name and say they should never get the treatment.

@compiler-errors
Copy link
Member

Sorry, gotta rebase this, and I saw some weird regressions in the UI tests with this heuristic...

One way to achieve this: if the where bounds for the impl include the "notable trait", don't consider that impl eligible for ⓘ treatment.

@compiler-errors
Copy link
Member

Ugh, sorry, probably won't get around to fixing this. I'll unclaim.

@compiler-errors compiler-errors removed their assignment Sep 29, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue Oct 26, 2022
…meGomez

rustdoc: don't mark Box<T> as Iterator, Read, etc

Because Box<T> has pass-through implementations, rustdoc was giving it the "Notable Traits" treatment for Iterator, Read, Write, and Future, even when the type of T was unspecified.

Pin had the same problem, but just for Future.

Fixes rust-lang#100320
@bors bors closed this as completed in ec7ffdf Oct 27, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
…meGomez

rustdoc: don't mark Box<T> as Iterator, Read, etc

Because Box<T> has pass-through implementations, rustdoc was giving it the "Notable Traits" treatment for Iterator, Read, Write, and Future, even when the type of T was unspecified.

Pin had the same problem, but just for Future.

Fixes rust-lang#100320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants