Skip to content

rustdoc: Rustdoc lists associated consts from trait impls in sidebar #95459

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

Closed
Jules-Bertholet opened this issue Mar 30, 2022 · 3 comments · Fixed by #95475
Closed

rustdoc: Rustdoc lists associated consts from trait impls in sidebar #95459

Jules-Bertholet opened this issue Mar 30, 2022 · 3 comments · Fixed by #95475
Labels
C-bug Category: This is a bug.

Comments

@Jules-Bertholet
Copy link
Contributor

I tried this code:

pub struct Foo;

pub trait Trait {
    const BAR: usize;
}

impl Trait for Foo {
    const BAR: usize = 42;
}

I expected to see this happen:
I would expect BAR not to appear as its own item in the rustdoc sidebar for the Foo struct.
This would be consistent with the behavior of methods and associated types from trait impls,
which also don't appear as their own item in the sidebar.

Instead, this happened:
The constant BAR is listed under "Associated Constants" in the left-hand sidebar of the rustdoc page for Foo.
This is inconsistent with how methods from trait impls appear in documentation.

rustdoc bug

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (1d9c262ee 2022-03-26)
binary: rustc
commit-hash: 1d9c262eea411ec5230f8a4c9ba50b3647064da4
commit-date: 2022-03-26
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0
@Jules-Bertholet Jules-Bertholet added the C-bug Category: This is a bug. label Mar 30, 2022
@fmease
Copy link
Member

fmease commented Mar 30, 2022

This was intentionally added in #89815.

@Jules-Bertholet
Copy link
Contributor Author

Jules-Bertholet commented Mar 30, 2022

@fmease The inclusion of associated consts from inherent impls is intentional. But is it intentional that associated consts from trait impls also appear in the sidebar (even though methods from trait impls do not)?

(I'm filing this bug because for a crate I'm developing, the current behavior makes the sidebar extremely messy. Restricting the list of associated constants to those from inherent impls would make navigating the documentation for my crate much more pleasant.)

@jsha
Copy link
Contributor

jsha commented Mar 31, 2022

I think the behavior @Jules-Bertholet proposes makes sense.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 31, 2022
…consts-from-trait-impls, r=jsha

rustdoc: Only show associated consts from inherent impls in sidebar

Resolves rust-lang#95459
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 1, 2022
…consts-from-trait-impls, r=jsha

rustdoc: Only show associated consts from inherent impls in sidebar

Resolves rust-lang#95459
@bors bors closed this as completed in e21b27f Apr 1, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants