Skip to content

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

Closed
@dtolnay

Description

@dtolnay
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions