Skip to content
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

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

Open
ilyvion opened this issue Nov 25, 2019 · 2 comments
Open

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

ilyvion opened this issue Nov 25, 2019 · 2 comments
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

@ilyvion
Copy link

ilyvion commented Nov 25, 2019

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.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 25, 2019
@ragnese
Copy link

ragnese commented Mar 18, 2020

Question: Does rustdoc (generally) de-alias when the type is private? Or will it sometimes show a private type alias?

@mortendahl
Copy link

Is any work being done on this? I'm running into the same issue.

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

No branches or pull requests

4 participants