Skip to content

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

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

Open
folkertdev opened this issue May 7, 2025 · 1 comment · May be fixed by #140863
Open

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

folkertdev opened this issue May 7, 2025 · 1 comment · May be fixed by #140863
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@folkertdev
Copy link
Contributor

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

@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 7, 2025
@GuillaumeGomez GuillaumeGomez added C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 9, 2025
@GuillaumeGomez
Copy link
Member

Taking a look.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 9, 2025
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. 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