Skip to content

Show implementations on typedefs on their page (or show a way to request such impls) #55408

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

Closed
Manishearth opened this issue Oct 27, 2018 · 7 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Manishearth
Copy link
Member

For example, this type doesn't list its impls, they can be found here which is kind of counterintuitive.

Ideally, if you have type Foo = Bar<Baz>;, it should show impl Bar<Baz> {} blocks (and perhaps impl Bar too?)

cc @QuietMisdreavus @GuillaumeGomez

@Manishearth Manishearth added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Oct 27, 2018
@Manishearth
Copy link
Member Author

Additionally, for "wrapper" types you should be able to find impls on their specializations on the inner type page, really: impl Foo for Rc<Baz> should show up on Baz's page, or should have a mechanism for being requested to show up on Baz's page (there's an alternate proposal to solve this in #55409)

@ollie27
Copy link
Member

ollie27 commented Oct 27, 2018

This looks like a duplicate of #32077.

Additionally, for "wrapper" types you should be able to find impls on their specializations on the inner type page, really: impl Foo for Rc<Baz> should show up on Baz's page

I think that's already the case, impl<'a> From<&'a OsStr> for Rc<OsStr> shows on the page for OsStr.

@Manishearth
Copy link
Member Author

Manishearth commented Oct 27, 2018

Doesn't work on this simple testcase:

pub struct Rc<T>(T);

pub struct Foo;


impl Rc<Foo> {
    pub fn bar() {}
}

@QuietMisdreavus
Copy link
Member

Right now, if you have pub type Asdf = Foo<Bar>, rustdoc will show any impls directly on Asdf. (That was #42027.) Attempting to go farther and display impls on Foo<Bar> would require rustdoc to query the definition on the type alias, including its type and lifetime parameters and their bounds, then be able to check against impls on the "real" type (potentially recursively, if a type alias is given in terms of another alias!).

It looks like #32077 has become "document all available impls on type aliases based on their definition", and this sounds like the same.

@Manishearth Also, your code sample is incomplete; i don't see how that is related to type aliases.

@Manishearth
Copy link
Member Author

@QuietMisdreavus it's related to my followup comment about wrapper types

@QuietMisdreavus
Copy link
Member

If the wrapper type implements Deref/DerefMut, then the applicable methods will appear on the wrapper's page. if you're asking for bar() to appear on Foo's page, then we have to be able to be able to mark such types as "transparent" somehow so rustdoc knows to add those methods in. (Do we change how we handle Deref so that methods directly on Deref-able wrappers appear on their Targets?)

In any case, that would make this thread about two problems; one about type aliases and the other about Deref. Please file a second issue to split these.

@Manishearth
Copy link
Member Author

#55551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

3 participants