Skip to content

rustdoc: type alias does not show the repr of the aliased type #140739

Closed
@folkertdev

Description

@folkertdev

I know the displaying of #[repr(...)] in general has some issues, and this certainly seems related.

Currently the aliased type is stored as a TypeAliasInnerType, which does not have enough info to find the original ADT and render the repr (or other attributes, for that matter). For example:

#[repr(C)]
pub struct Foo {
    a: u8,
    pub b: u8,
    c: u8,
    pub d: u8,
    e: u8,
}

pub type Bar = Foo;

where Foo is rendered as

#[repr(C)]
pub struct Foo {
    pub b: u8,
    pub d: u8,
    /* private fields */
}

but on the docs page for Bar it is

struct Bar {
    pub b: u8,
    pub d: u8,
    /* private fields */
}

The example also hits #66401, so I think the proper solution is to really use the exact same rendering code for the aliased types as for the original type. That prevents such mismatches, though I may be missing why that was not done in the first place, maybe there is a good reason.

@rustbot label +T-rustdoc

Metadata

Metadata

Assignees

No one assigned

    Labels

    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