In rustdoc, omit trait impls that a user cannot call

6a9d004
Opened by David Tolnay at 2022-01-18 22:16:36
pub struct Public;
struct Private;

impl From<Private> for Public {
    fn from(_: Private) -> Self {
        unimplemented!()
    }
}

The rustdoc of Public displays a From impl that cannot be invoked by users of the crate.

selection_057

I'm sure there are lots of edge cases to consider, but this is a common pattern especially for error types for use with ?. It would be nice to hide such impls from rustdoc without requiring the crate author to tag them with #[doc(hidden)].

This came up during the libz blitz evaluation of the reqwest crate. https://github.com/seanmonstar/reqwest/issues/106

  1. I'd go one step further and hide or de-prioritize/collapse even more useless information in inlined trait documentation:

    • Methods with unsatisfiable where clauses (e.g. Self: NotImplementedTrait) to simplify the documentation (make it shorter and easier to tell what methods are available at a glance).
    • Always satisfied constraints in where clauses (e.g. where Self: Sized for sized types).

    Steven Allen at 2017-06-11 21:30:14