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 does not show documentation on empty impl blocks #90866

Closed
jyn514 opened this issue Nov 13, 2021 · 3 comments · Fixed by #90905
Closed

Rustdoc does not show documentation on empty impl blocks #90866

jyn514 opened this issue Nov 13, 2021 · 3 comments · Fixed by #90905
Assignees
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Nov 13, 2021

I tried this code:

struct Ty {}
/// Documentation 1
impl Ty {}

I expected to see this happen: Either the comment should show up in the generated docs, or rustdoc/rustc should issue a warning.

Instead, this happened: The documentation is silently ignored.

I think we should show the documentation, since people like to use impl blocks for grouping and it's possible that all the items in the impl have a #[cfg()] macro that's false.

Thanks @WaffleLapkin for the bug report and @GuillaumeGomez for giving feedback on the proper fix.

Meta

rustdoc --version --verbose: rustdoc 1.58.0-nightly (e90c5fb 2021-11-12)

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Nov 13, 2021
@GuillaumeGomez
Copy link
Member

I'll write the fix in the next days.

@GuillaumeGomez GuillaumeGomez self-assigned this Nov 13, 2021
@kpreid
Copy link
Contributor

kpreid commented Nov 13, 2021

A suggestion: Since this is such an unusual case, add a special note like

This impl TypeName {} contains no items.

after the displayed documentation. This will help people parse the structure of the documentation page, understand what it means that the thing is said to be an implementation, and understand that it's not purely a rustdoc bug/infelicity that it's showing an empty section.

@GuillaumeGomez
Copy link
Member

Good idea!

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 5, 2022
…=jsha

Add empty impl blocks if they have documentation

Fixes rust-lang#90866.

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with rust-lang#89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc `@Mark-Simulacrum).`

It looks like this:

![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png)

cc `@jyn514`
r? `@camelid`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 6, 2022
…=jsha

Add empty impl blocks if they have documentation

Fixes rust-lang#90866.

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with rust-lang#89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ``@Mark-Simulacrum).``

It looks like this:

![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png)

cc ``@jyn514``
r? ``@camelid``
@bors bors closed this as completed in 77f0209 Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

3 participants