Skip to content

bad rustdoc ux: trait method implementations have their docstrings ommitted in the "implementors" section #92641

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

Open
safinaskar opened this issue Jan 7, 2022 · 5 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@safinaskar
Copy link
Contributor

I opened documentation of FromIterator ( https://doc.rust-lang.org/std/iter/trait.FromIterator.html ), then I scrolled to section "Implementors" and found this implementation:

impl<A, E, V> FromIterator<Result<A, E>> for Result<V, E>
where
    V: FromIterator<A>,

This implementation was not documented on this page. I clicked "[src]" and was able to see docs in source. So, I thought that there is some bug in rustdoc, which causes this docs not to render. Then I opened page on Result ( https://doc.rust-lang.org/std/result/enum.Result.html ) and (susprisiongly) found that this impl is documented there! So, for unknown reasons rustdoc shows this doc on Result page, but doesn't show it on FromIterator page

@safinaskar safinaskar added the C-bug Category: This is a bug. label Jan 7, 2022
@Nemo157 Nemo157 added A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 10, 2022
@fmease
Copy link
Member

fmease commented Aug 12, 2022

This issue seems to have been fixed at some unknown point in time. It should be closed. (see comments below)

Result is now documented as an implementor on the FromIterator page.
For completeness, here is the link to the FromIterator impl on the Result page.

@safinaskar
Copy link
Contributor Author

@fmease , I still don't see docs at link you provided. I mean I see implementation itself, but I don't see docs, i. e. I don't see text "Takes each element in the Iterator: if it is an Err, no further..."

My browser is Google Chrome 103.0.5060.53 on Debian Stretch

@fmease
Copy link
Member

fmease commented Aug 13, 2022

Oh my bad, I misread the issue.

The documentation Takes each element […] is not shown on the FromIterator page because it belongs to the method from_iter and not to the impl block and rustdoc doesn't display any associated items (like in this case from_iter) in a trait's Implementors section but only the “headers” of impl blocks (to save disk space and reduce render time I think).

All in all, this doesn't appear to be a rustdoc issue.
However, the question might still remain whether the doc comments should be moved from the method to the impl block. Not sure. The current location looks fine to me.

@safinaskar
Copy link
Contributor Author

@fmease , thanks for explanation.

I think rustdoc should show full docs in implementors. Or at least provide a link to full docs. In current form this docs are too hard to find

@lolbinarycat lolbinarycat added C-discussion Category: Discussion or questions that doesn't represent real issues. C-bug Category: This is a bug. and removed C-bug Category: This is a bug. C-discussion Category: Discussion or questions that doesn't represent real issues. labels Nov 8, 2024
@lolbinarycat lolbinarycat changed the title UX/UI rustdoc error: "impl FromIterator for Result" is not documented on FromIterator page bad rustdoc ux: trait method implementations have their docstrings ommitted in the "implementors" section Nov 8, 2024
@lolbinarycat
Copy link
Contributor

clarifying this issue because it took me a bit to understand:

if you go to the "implementors" section on a trait page, you will simply get a list of impl items, along with any documentation that appears on the block itself:

Image

if you go to the "trait implementations" section on a type page, you will get a collapsible list of impl blocks, including the contents of the impl block, such as documentation on method implemenations:

Image

this inconsistency is confusing, since, for traits that have only a single method, implementors sometimes document details of their implementation on that method, and sometimes they do so on the impl block itself.

@lolbinarycat lolbinarycat added A-trait-system Area: Trait system A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. labels Nov 8, 2024
@fmease fmease removed the A-trait-system Area: Trait system label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants