Skip to content

Commit 44813e0

Browse files
committed
rustdoc: fix type search when more than one where clause applies
1 parent a6446c5 commit 44813e0

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

src/librustdoc/html/render/search_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
484484
// for its bounds.
485485
if let Type::Generic(arg_s) = *arg {
486486
// First we check if the bounds are in a `where` predicate...
487-
if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g {
487+
for where_pred in generics.where_predicates.iter().filter(|g| match g {
488488
WherePredicate::BoundPredicate { ty: Type::Generic(ty_s), .. } => *ty_s == arg_s,
489489
_ => false,
490490
}) {
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
const QUERY = 'option, fnonce -> option';
1+
const QUERY = [
2+
'option, fnonce -> option',
3+
'option -> default',
4+
];
25

3-
const EXPECTED = {
4-
'others': [
5-
{ 'path': 'std::option::Option', 'name': 'map' },
6-
],
7-
};
6+
const EXPECTED = [
7+
{
8+
'others': [
9+
{ 'path': 'std::option::Option', 'name': 'map' },
10+
],
11+
},
12+
{
13+
'others': [
14+
{ 'path': 'std::option::Option', 'name': 'unwrap_or_default' },
15+
{ 'path': 'std::option::Option', 'name': 'get_or_insert_default' },
16+
],
17+
},
18+
];

tests/rustdoc-js/where-clause.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const QUERY = ['trait<nested>', '-> trait<nested>', 't1, t2', '-> shazam'];
1+
const QUERY = ['trait<nested>', '-> trait<nested>', 't1, t2', '-> shazam', 'drizzel -> shazam'];
22

33
const EXPECTED = [
44
{
@@ -19,6 +19,12 @@ const EXPECTED = [
1919
{
2020
'others': [
2121
{ 'path': 'where_clause', 'name': 'bippety' },
22+
{ 'path': 'where_clause::Drizzel', 'name': 'boppety' },
23+
],
24+
},
25+
{
26+
'others': [
27+
{ 'path': 'where_clause::Drizzel', 'name': 'boppety' },
2228
],
2329
},
2430
];

tests/rustdoc-js/where-clause.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ pub trait Shazam {}
2020
pub fn bippety<X>() -> &'static X where X: Shazam {
2121
panic!()
2222
}
23+
24+
pub struct Drizzel<T>(T);
25+
26+
impl<T> Drizzel<T> {
27+
pub fn boppety(&self) -> &T where T: Shazam {
28+
panic!();
29+
}
30+
}

0 commit comments

Comments
 (0)