Skip to content

Rustdoc shows = _ needlessly in non-trait associated constants #134320

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
dtolnay opened this issue Dec 14, 2024 · 0 comments · Fixed by #134321
Closed

Rustdoc shows = _ needlessly in non-trait associated constants #134320

dtolnay opened this issue Dec 14, 2024 · 0 comments · Fixed by #134321
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 14, 2024

pub struct Struct;

pub trait Trait {
    const REQUIRED: Struct;
    const OPTIONAL: Struct = Struct {};
}

impl Trait for Struct {
    const REQUIRED: Struct = Struct {};
    const OPTIONAL: Struct = Struct {};
}

impl Struct {
    pub const INHERENT: Struct = Struct {};
}

 

In the trait's documentation, rustdoc renders const REQUIRED: Struct; and const OPTIONAL: Struct = _;. Here the = _ is meaningful because it signals that a trait's associated constant has some default value provided by the trait, even if that default value cannot be rendered.

But in the struct's documentation, none of the 3 = _ are meaningful. All three are just noise and should be omitted.

@dtolnay dtolnay added A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 14, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 14, 2024
@fmease fmease self-assigned this Dec 14, 2024
@fmease fmease removed their assignment Dec 14, 2024
@bors bors closed this as completed in f14d69c Dec 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) 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