Skip to content

Commit f068d8b

Browse files
committed
rustdoc-search: show impl Trait inline when unhighlighted
While normal generics can be skipped in this case, no-names need something to show here. Before: `TyCtxt, , Symbol -> bool` After: `TyCtxt, Into<DefId>, Symbol -> bool`
1 parent 4847d6a commit f068d8b

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,12 @@ class DocSearch {
25922592
const writeFn = (fnType, result) => {
25932593
if (fnType.id < 0) {
25942594
if (fnParamNames[-1 - fnType.id] === "") {
2595-
for (const nested of fnType.generics) {
2595+
// Normally, there's no need to shown an unhighlighted
2596+
// where clause, but if it's impl Trait, then we do.
2597+
const generics = fnType.generics.length > 0 ?
2598+
fnType.generics :
2599+
obj.type.where_clause[-1 - fnType.id];
2600+
for (const nested of generics) {
25962601
writeFn(nested, result);
25972602
}
25982603
return;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// exact-check
2+
// ignore-order
3+
4+
const EXPECTED = [
5+
{
6+
'query': 'tyctxt, symbol -> bool',
7+
'others': [
8+
{
9+
'path': 'foo::TyCtxt',
10+
'name': 'has_attr',
11+
'displayType': "`TyCtxt`, Into<DefId>, `Symbol` -> `bool`",
12+
},
13+
],
14+
},
15+
{
16+
'query': 'tyctxt, into<defid>, symbol -> bool',
17+
'others': [
18+
{
19+
'path': 'foo::TyCtxt',
20+
'name': 'has_attr',
21+
'displayType': "`TyCtxt`, `Into`<`DefId`>, `Symbol` -> `bool`",
22+
},
23+
],
24+
},
25+
];
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![crate_name="foo"]
2+
3+
pub struct TyCtxt;
4+
pub struct DefId;
5+
pub struct Symbol;
6+
7+
impl TyCtxt {
8+
pub fn has_attr(self, _did: impl Into<DefId>, _attr: Symbol) -> bool {
9+
unimplemented!();
10+
}
11+
}

0 commit comments

Comments
 (0)