Skip to content

Commit a6446c5

Browse files
committed
rustdoc: fix type search index for fn<T>() -> &T where T: Trait
1 parent 0a3b557 commit a6446c5

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/librustdoc/html/render/search_index.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
465465
}
466466

467467
// First, check if it's "Self".
468-
let arg = if let Some(self_) = self_ {
468+
let mut arg = if let Some(self_) = self_ {
469469
match &*arg {
470470
Type::BorrowedRef { type_, .. } if type_.is_self_type() => self_,
471471
type_ if type_.is_self_type() => self_,
@@ -475,6 +475,11 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
475475
arg
476476
};
477477

478+
// strip references from the argument type
479+
while let Type::BorrowedRef { type_, .. } = &*arg {
480+
arg = &*type_;
481+
}
482+
478483
// If this argument is a type parameter and not a trait bound or a type, we need to look
479484
// for its bounds.
480485
if let Type::Generic(arg_s) = *arg {

tests/rustdoc-js/where-clause.js

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

33
const EXPECTED = [
44
{
@@ -16,4 +16,9 @@ const EXPECTED = [
1616
{ 'path': 'where_clause', 'name': 'presto' },
1717
],
1818
},
19+
{
20+
'others': [
21+
{ 'path': 'where_clause', 'name': 'bippety' },
22+
],
23+
},
1924
];

tests/rustdoc-js/where-clause.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ pub trait T2<'a, T> {
1414
}
1515

1616
pub fn presto<A, B>(_: A, _: B) where A: T1, B: for <'b> T2<'b, Nested> {}
17+
18+
pub trait Shazam {}
19+
20+
pub fn bippety<X>() -> &'static X where X: Shazam {
21+
panic!()
22+
}

0 commit comments

Comments
 (0)