-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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: disambiguate between types of the same name #42066
Comments
Related to #34999. |
I just wonder: should we add the path only when the item is present more than once or should we do it everytime? |
As in, print the full path regardless of whether it shares its short-name with anything? I suppose that could work. It'd certainly be easier to implement, though it risks being overly verbose. |
That's my main concern. |
Looks like this is a more general version of #16096. |
Always printing the full path would make the docs vastly more useful for me. Even if a name isn't reused, it's still important to see where it's actually coming from. But for reused names this is really important, since re-using the same name in many related crates is common practice. (E.g. today I was trying to figure something out with bincode, and ended up on https://docs.rs/bincode/1.0.0-alpha7/bincode/type.Serializer.html. The doc reads: type Serializer = Serializer<W, LittleEndian>; This is not useful at all. Clicking on the last |
@jyn514 mentioned it might be worth posting my OP at #65330 (a duplicate issue) to the main discussion here, but it looks like a lot of my points have already been covered here so I'll just leave it at a link.
My personal preference would be to prepend the parent modules until there can no longer be any ambiguity to which type is referred to. The paths to some types can get incredibly long. If the full path didn't help to disambiguate the type, I imagine it might just appear a bit noisy. From #65330,
|
I think it should be per-page, not for the whole crate. Otherwise you'd get lots of false positives from dependencies when you really are interested in disambiguating the current page. |
Can you elaborate on what you mean by per-page? Personally, I'm interested in disambiguating between all of the types with the same name within the current crate and all its dependencies - not just potential name conflicts that appear on the current page. When reading docs, I'd like to be able to know which of the possible set of types is being referred to (of all public types that share the same name within this crate and its dependencies) without having to click on the type and wait for a page to load or hover over it and wait for a hint to appear to work it out. |
So, obviously this is very confusing and should be fixed (from #74924, https://docs.serde.rs/serde_json/struct.Error.html#trait-implementations): But what about If we always disambiguated when there was a duplicate name anywhere in the dependency tree, rustdoc would always use |
If the E.g. impl Error for ParseError Knowing that serde is a dependency, it is unclear which
I would love this! I think for beginners especially it's easy to get confused between All that said, I'm not sure how this would affect the std library more generally, as both |
Here's an example of total failure with ambiguous names (link is not to docs.rs because the identifier is not present in latest release): https://docs.iced.rs/iced_renderer/type.Compositor.html (version 0.13.0-dev) pub type Compositor = Compositor<Compositor, Compositor>; You have to hover the links to make any sense of that. |
There is a work in progress on that. I should check what's the current status... cc @krtab |
Hi everyone, |
As an extension to #38414 and #39589, any hyperlinked reference to some type should be checked against everything within that crate - within any dependent crate too, if possible. This will help clear the confusion between the perennial problem types in std,
std::result::Result
andstd::io::Result
(and to a lesser extent,std::io::Write
andstd::fmt::Write
).Some before/after screenshots made with chrome's inspector with what I have in mind:
The text was updated successfully, but these errors were encountered: