Skip to content

rustdoc search doesn't handle non-trait impls in a different module to the type definition #10284

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
huonw opened this issue Nov 5, 2013 · 3 comments · Fixed by #12752
Closed
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@huonw
Copy link
Member

huonw commented Nov 5, 2013

std::path::Path has some methods impl'd in std::rt::io::fs; searching for, e.g., exists links to std::rt::io::fs::Path as if the struct was defined there.

@huonw
Copy link
Member Author

huonw commented Mar 6, 2014

Self contained example:

#[crate_id="10284"];

pub mod foo {
    pub struct Bar;
}

pub mod bar {
    impl ::foo::Bar {
        pub fn baz(&self) {}
    }
}

Searching for baz in the generated docs links to a nonexistent page.

@edwardw
Copy link
Contributor

edwardw commented Mar 7, 2014

This is surprisingly arcane. The method index is built here and it depends on the order of parsing. I had a fix but a seemingly irrelevant syntactical change easily broke it:

#[crate_id="10284"];

pub mod bar {
    impl ::foo::Zar {
        pub fn baz(&self) {}
    }
}

pub mod foo {
    pub struct Zar;
}

For the same reason, the fix also didn't work for Path::stat given in #12728: std::io::fs is parsed before std::path::posix::Path so the poor Path::stat couldn't find the right parent node.

@edwardw
Copy link
Contributor

edwardw commented Mar 7, 2014

r?

bors added a commit that referenced this issue Mar 8, 2014
A structure's definition and implementation may be cross-module. If the
implementing module is parsed before defining module, the fully
qualified name of the structure won't be present for the implementation
to use when being indexed. So caches such 'orphan' implementation and
indexes it at the end of crate parsing.

Closes #10284.
@bors bors closed this as completed in a337592 Mar 8, 2014
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

Successfully merging a pull request may close this issue.

2 participants