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: render references to associated type using short form when possible #21145

Closed
aturon opened this issue Jan 14, 2015 · 3 comments
Closed
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aturon
Copy link
Member

aturon commented Jan 14, 2015

Currently, rustdoc renders the Index trait as:

pub trait Index<Index> where Index: ?Sized {
    type Output;
    fn index(&'a self, index: &Index) -> &'a <Self as Index<Index>>::Output;
}

Ideally it would render as

pub trait Index<Index> where Index: ?Sized {
    type Output;
    fn index(&'a self, index: &Index) -> &'a Self::Output;
}

and eventually, when the scoping rules for associated items are settled, it could skip even the Self::

@aturon aturon added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 14, 2015
@aturon
Copy link
Member Author

aturon commented Jan 14, 2015

cc @tomjakubowski

@tomjakubowski
Copy link
Contributor

Hmmm yep. We need to either pass the trait's type all the way down (maybe as some kind of QualifyContext type) when cleaning its items, or just tidy up any eligible QPaths afterwards.

@tomjakubowski
Copy link
Contributor

So this particular bug only happens for cross-crate inlined traits. But it's broken in a different way in core, where Self is missing from the type entirely!

pub trait Index<Index: ?Sized> {
    type Output: ?Sized;

    fn index<'a>(&'a self, index: &Index) -> &'a Output;
}

tomjakubowski added a commit to tomjakubowski/rust that referenced this issue Feb 6, 2015
(e.g., `Self::Output`)

This doesn't actually "resugar" qualified paths like `<Self as
Foo>::Output`, it just doesn't elide the prefix segments when rendering
cleaned paths like `Self::Output`.

cc rust-lang#21145
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

2 participants