Uh oh!
There was an error while loading. Please reload this page.
[Rustdoc] save generic type data to index + basic search - #26356
[Rustdoc] save generic type data to index + basic search#26356mihneadb wants to merge 6 commits into
Conversation
rust-highfive
commented
Jun 16, 2015
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
mihneadb
commented
Jun 18, 2015
There was a problem hiding this comment.
Why Box<Vec<..>>? This is only useful in rare cases, Vec itself is already only three usize large.
There was a problem hiding this comment.
Because I didn't know any better :). It was Box<Type> initially to avoid infinite recursion, and when I changed to Vec I didn't reconsider the Box. Will change, thanks!
bluss
commented
Jun 18, 2015
What's the impact on the search index file size? This is especially interesting/important for libstd. |
mihneadb
commented
Jun 19, 2015
|
mihneadb
commented
Jun 20, 2015
alexcrichton
commented
Jun 29, 2015
I'm somewhat wary about how we can effectively make use of this in searches, it looks like you want to match generic functions against searching for a signature, but there's no guarantee that generics with a bound are actually satisfied as part of the query, so it's possible to get a lot of bogus examples, right? |
mihneadb
commented
Jun 29, 2015
That's correct, trait bounds are not handled in any way. I felt it would be too big of a project in itself and that this could be done incrementally. However, if you think it might not be too useful as it is, feel free to close this and maybe it can be reused later 😄. |
Gankra
commented
Jul 27, 2015
@alexcrichton what's your verdict? |
alexcrichton
commented
Jul 27, 2015
Ok, I'm a little worried about how the search is fairly lossy (doesn't match bounds, may not work on |
bluss
commented
Jul 27, 2015
Haskell's hoogle is a separate project, I think (separate from their doc generator)? Maybe this too could develop faster and more productively as a separate project. |

This PR adds more complex type data for generics to the search index, such as:
for
fn identity<T>(x: T) -> T, andfor
fn generic_option_stuff<T>(x: Option<T>) -> i32On the frontend side, searches such as
char -> charwill match theidentityfunction above. Similarly,string, string ->will matchstd::env::set_var. So the search logic only tries to particularize generic types against the given query. It only does so for "base" generic types (i.e.T, notOption<T>) -- but the information for this is already in the index, it's only the JS logic that needs improving.A problem that I couldn't figure out how to solve is getting the full type information for
self. Currently, we have access to the type's name (via the parent stack, implemented in #23289), but that means for example that for a method on something likeMyOption<T>we only getname: myoption, generic: false. Also, please note that this does not take trait bounds into account. (#mvp)cc @alexcrichton