Skip to content

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

Closed
@Jules-Bertholet

Description

@Jules-Bertholet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions