Nothing Special   »   [go: up one dir, main page]

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

Types made public via associated types are not documented #60686

Open
nagisa opened this issue May 9, 2019 · 4 comments
Open

Types made public via associated types are not documented #60686

nagisa opened this issue May 9, 2019 · 4 comments
Labels
A-reachable-priv Issues involving private types that are indirectly reachable or effect the public api C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@nagisa
Copy link
Member
nagisa commented May 9, 2019

Given following code:

mod raspberry {
    pub struct Banana;
}

pub struct Peach;

pub trait Apple {
    type Juice;
}

impl Apple for Peach {
    type Juice = raspberry::Banana;
}

The generated documentation will not include documentation for <Peach as Apple>::Juice.

Screenshot_2019-05-10 lib Peach - Rust

@nagisa nagisa added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 9, 2019
@cuviper
Copy link
Member
cuviper commented May 10, 2019

Isn't this true of any pub-in-private use? i.e. not just associated types, but also parameters, return values, trait constraints, etc. There's no publicly reachable path to Banana, so it don't get docs.

However, if you put doc comments on the type Juice, it does generate documentation there.

@jyn514
Copy link
Member
jyn514 commented Nov 5, 2020

@nagisa do you still think this is a bug? I'm not sure what rustdoc could do differently here.

@nagisa
Copy link
Member Author
nagisa commented Nov 15, 2020

Yeah, I still consider it a bug, provided the original example behaves as it did when this was initially reported. It effectively fails to generate documentation for a public item, which is a major issue if the Banana type happens to be important in some way.

I also think it is an important bug to resolve because it is fairly easy to design a library around a concept such as this without ever noticing that there will be consequences in terms of generated documentation. (Who really checks the generated documentation before publishing crates?)

There's no publicly reachable path to Banana, so it don't get docs.

<Peach as Apple>::Juice is one such public path. As in, anywhere in the code specifying this will give you a Banana, even if you cannot refer to it in a more direct way. At the type system level I believe it will also directly refer to Banana as well, as opposed to considering it an associated type, with all of the relevant caveats.

Parameters and return values are slightly different as you cannot explicitly refer to those types elsewhere in the code. As thus I consider them of significantly lower importance. Public-private arguments are also used for privacy hacks, so it isn't as clear whether those ought to be documented.

@camelid
Copy link
Member
camelid commented Dec 17, 2020

Totally off-topic: I want to see more of this code! It's mouthwatering ;) 🍓

@lolbinarycat lolbinarycat added the A-reachable-priv Issues involving private types that are indirectly reachable or effect the public api label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-reachable-priv Issues involving private types that are indirectly reachable or effect the public api 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

5 participants