-
Notifications
You must be signed in to change notification settings - Fork 13k
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: Trait implementors could show associated types as well #24200
Comments
I'm strongly in favor of this. I didn't actually realize rustdoc was showing associated types in the list of traits for a concrete type, since I often look at the list of implementors for a specific trait instead. A simple suggestion would be to use the inline shorthand notation, so e.g. impl<T> Index<usize, Output=T> for [T]
impl Index<Range<usize>, Output=str> for String |
Additionally, with generic implementations there may not even be a impl<T> ToOwned for [T] where T: Clone Presumably |
There's another problem similar to the one @Diggsey describes that this would resolve. If crate CA implements a trait with an associated type for a type TB from crate CB, you can't find out the associated type from the docs. The normal way would be to look at the documentation for TB, but that is not necessarily included with the CA documentation. |
I guess a src-link for |
This is also a problem in the futures crate, where there are impl<A, B> IntoFuture for (A, B) where
A: IntoFuture,
B: IntoFuture<Error = A::Error>, In that case it would also be very helpful to show the impl blocks documentation on the trait page, which I didn't find an existing issue for. Without either piece of information, it is impossible to know whether this About the extra output potentially cluttering the doc page: What about having the extra information hidden by default, with one of those |
I opened #43515 to fix this. |
…omez rustdoc: print associated types in traits "implementors" section When viewing a trait's implementors, they won't show anything about the implementation other than any bounds on the generics. You can see the full implementation details on the page for the type, but if the type is external (e.g. it's an extension trait being implemented for primitives), then you'll never be able to see the details of the implementation without opening the source code. This doesn't solve everything about that, but it does still show an incredibly useful piece of information: the associated types. This can help immensely for traits like `Deref` or `IntoIterator` in libstd, and also for traits like `IntoFuture` outside the standard library. Fixes #24200 🚨 BIKESHED ALERT 🚨 The indentation and sizing of the types is suspect. I put it in the small text so it wouldn't blend in with the next impl line. (It shares a CSS class with the where clauses, as you can see in the following image.) However, the indentation is nonstandard. I initially tried with no indentation (looked awkward and blended too well with the surrounding impls) and with 4-space indentation (too easy to confuse with where clauses), before settling on the 2-space indentation seen below. It's... okay, i guess. Open to suggestions. ![snippet of the implementors of IntoIterator, showing the associated types](https://user-images.githubusercontent.com/5217170/28697456-a4e01a12-7301-11e7-868e-2a6441d6c9e0.png)
For example there are many implementors of the
Deref
trait, but you have to follow through on theSelf
type to see what the associated types are.Rustdoc may want to show associated type bindings there as well (but the clutter should be evaluated).
cc #21092, the original issue
The text was updated successfully, but these errors were encountered: