Skip to content

rustdoc: Associated type fixes #25675

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

Merged
merged 3 commits into from
May 26, 2015
Merged

Conversation

bluss
Copy link
Member

@bluss bluss commented May 21, 2015

rustdoc: Associated type fixes

The first commit fixes a bug with "dud" items in the search index from
misrepresented type items in trait impl blocks.

For a trait implementation there are typedefs which are the types for
that particular trait and implementor. Skip these in the search index.

There were lots of dud items in the search index due to this (search for
Item, Iterator's associated type).

Add a boolean to clean::TypedefItem so that it tracks whether the it is
a type alias on its own, or if it's a type item in a trait impl.

The second commit fixes a bug that made signatures and where bounds
using associated types (if they were not on Self) incorrect.

The third commit fixes so that where clauses in type alias definititons
are shown.

Fixes #22442
Fixes #24417
Fixes #25769

For a trait *implementation* there are typedefs which are the types for
that particular trait and implementor. Skip these in the search index.

There were lots of dud items in the search index due to this (search for
Item, Iterator's associated type).

Add a boolean to clean::TypedefItem so that it tracks whether the it is
a type alias on its own, or if it's a `type` item in a trait impl.

Fixes rust-lang#22442
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cmr (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@bluss bluss changed the title rustdoc: Skip types in impls in search index rustdoc: Associated type fixes May 25, 2015
@bluss bluss force-pushed the rustdoc-assoc-types-index branch from 174c619 to 4ba6715 Compare May 25, 2015 16:46
@bluss
Copy link
Member Author

bluss commented May 25, 2015

I've got some associated type heavy modules and they look beautiful with this fix!!

Functions such as `fn foo<I: Iterator>(x: I::Item)` would not
render correctly and displayed `I` instead of `I::Item`. Same thing
with `I::Item` appearing in where bounds.

This fixes the bug by using paths for generics.

Fixes rust-lang#24417
@bluss bluss force-pushed the rustdoc-assoc-types-index branch from 4ba6715 to d1cd689 Compare May 25, 2015 17:07
Yes, it's allowed. Example:

    type MapFn<I, B> where I: Iterator = Map<I, fn(I::Item) -> B>;

Fixes rust-lang#25769
@bluss
Copy link
Member Author

bluss commented May 25, 2015

Now a type like this:

type CoalesceFn<I> where I: Iterator =
    Coalesce<I, fn(I::Item, I::Item) -> Result<I::Item, (I::Item, I::Item)>>;

renders correctly: (i.e. you can copy & paste it and it compiles)

screenshot of typedef

@alexcrichton
Copy link
Member

@bors: r+ 06304ed

Amazing! Thanks so much!

bors added a commit that referenced this pull request May 26, 2015
rustdoc: Associated type fixes

The first commit fixes a bug with "dud" items in the search index from
misrepresented `type` items in trait impl blocks.

For a trait *implementation* there are typedefs which are the types for
that particular trait and implementor. Skip these in the search index.

There were lots of dud items in the search index due to this (search for
Item, Iterator's associated type).

Add a boolean to clean::TypedefItem so that it tracks whether the it is
a type alias on its own, or if it's a `type` item in a trait impl.

The second commit fixes a bug that made signatures and where bounds
using associated types (if they were not on `Self`) incorrect.

The third commit fixes so that where clauses in type alias definititons
are shown.

Fixes #22442
Fixes #24417
Fixes #25769
@bors
Copy link
Collaborator

bors commented May 26, 2015

⌛ Testing commit 06304ed with merge cccc137...

@bors bors merged commit 06304ed into rust-lang:master May 26, 2015
@bluss bluss deleted the rustdoc-assoc-types-index branch May 26, 2015 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants