-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix primitive search in parameters and returned values #81557
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { | |
desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)), | ||
parent: Some(did), | ||
parent_idx: None, | ||
search_type: get_index_search_type(&item, None), | ||
search_type: get_index_search_type(&item, Some(cache)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure I understand what is happening here: This adds primitives to the cache, because now in an earlier stage they are being properly added to the cache via the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. To be more precise: the cache here is needed to get the |
||
}); | ||
for alias in item.attrs.get_doc_aliases() { | ||
cache | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// exact-check | ||
|
||
const QUERY = [ | ||
"i32", | ||
"str", | ||
"TotoIsSomewhere", | ||
]; | ||
|
||
const EXPECTED = [ | ||
{ | ||
'in_args': [ | ||
{ 'path': 'primitive', 'name': 'foo' }, | ||
], | ||
}, | ||
{ | ||
'returned': [ | ||
{ 'path': 'primitive', 'name': 'foo' }, | ||
], | ||
}, | ||
{ | ||
'others': [], | ||
'in_args': [], | ||
'returned': [], | ||
}, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub fn foo(i: i32) -> &'static str { | ||
"hello" | ||
} | ||
|
||
pub fn foo2<TotoIsSomewhere>(i: &TotoIsSomewhere, j: TotoIsSomewhere) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't always a primitive.
ty.def_id()
will returnNone
for generic parameters as well which shouldn't end up the in the search index.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! I'll fix that and add a test to ensure they're not listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no because we check before if it's a full generic. So it should never be the case. I'll add a test to ensure it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_full_generic
will only return true for generics passed by value. Generics passed by reference likepub fn foo<T>(x: &T) {}
or&self
show up in the search index with this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll add a
is_primitive
method then to ensure that.