Skip to content

Rustdoc unexpectedly de-aliases type aliases in some situations #66751

Open
@ilyvion

Description

@ilyvion

Here's a relatively minimal example that demonstrates the problem:

pub type Color1 = (u8, u8, u8, u8);

pub struct Color2 {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}

impl Color2 {
    pub fn new_with_alpha(r: u8, g: u8, b: u8, a: u8) -> Self {
        Self { r, g, b, a }
    }
}

impl From<Color2> for Color1 {
    fn from(c: Color2) -> Self {
        (c.r, c.g, c.b, c.a)
    }
}

impl From<Color1> for Color2 {
    fn from((r, g, b, a): Color1) -> Self {
        Self::new_with_alpha(r, g, b, a)
    }
}

If you run cargo doc on this, you'll get this:

image

As you can see, it says From<(u8, u8, u8, u8)> for Color2, despite saying Color1 everywhere else, including on the fn from(...) in the From implementation. I expected to get Color1 in the From<...> too.

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