Skip to content

rustdoc: Generates wrong signature for function with associated type parameter #24417

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
mbudde opened this issue Apr 14, 2015 · 7 comments · Fixed by #25675
Closed

rustdoc: Generates wrong signature for function with associated type parameter #24417

mbudde opened this issue Apr 14, 2015 · 7 comments · Fixed by #25675
Labels
P-medium Medium priority T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@mbudde
Copy link
Contributor

mbudde commented Apr 14, 2015

Create a library with the following src/lib.rs:

pub trait SomeTrait {
    type Typ;
}

pub struct Foo<T> {
    bar: T
}

impl<T: SomeTrait> Foo<T> {
    pub fn foo(&self, bar: T::Typ) {}
}

and run cargo doc. The documentation will show the type of Foo::foo as fn foo(&self, bar: T) and not fn foo(&self, bar: T::Typ) as expected.

rustdoc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)

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

You may want to try the nightly; a number of bugs have been fixed post-beta. Can you check?

@mbudde
Copy link
Contributor Author

mbudde commented Apr 14, 2015

@steveklabnik: I can reproduce with rustdoc 1.0.0-nightly (e6a812402 2015-04-14) (built 2015-04-14).

@steveklabnik
Copy link
Member

👍 thanks for checking.

@huonw
Copy link
Member

huonw commented Apr 16, 2015

triage: I-nominated

This can lead to some very confusing signatures, especially since associated types are quite widely used in the standard library with core types like iterators.

@mbudde
Copy link
Contributor Author

mbudde commented Apr 16, 2015

I ran into the problem while reading the documentation for mio. I have not been able to find any instances of this problem in the standard library (only a couple of hits in the librustc crate) [1] .

[1] git grep '\<fn[^(]*([^)]*[A-RT-Z][a-zA-Z_]*::[A-Z][^)]*)'

@pnkfelix
Copy link
Member

P-high, not 1.0. Seems nice to fix, but without an example of this bug occurring in the stdlib itself, it is not a 1.0 blocker.

@pnkfelix pnkfelix added P-medium Medium priority and removed I-nominated labels Apr 16, 2015
@bluss
Copy link
Member

bluss commented May 8, 2015

The exception seems to be associated types on Self. Those display.

Libcore displays this problem! But libstd does not. See .zip() in libcore and .zip() in libstd

bluss pushed a commit to bluss/rust that referenced this issue May 25, 2015
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 pushed a commit to bluss/rust that referenced this issue May 25, 2015
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 pushed a commit to bluss/rust that referenced this issue May 25, 2015
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
bors added a commit that referenced this issue 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
XMPPwocky pushed a commit to XMPPwocky/rust that referenced this issue May 29, 2015
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants