Skip to content

Commit

Permalink
rustdoc-search: fix bugs when unboxing and reordering combine
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Sep 9, 2023
1 parent 9ccb217 commit 269cb57
Show file tree
Hide file tree
Showing 6 changed files with 376 additions and 236 deletions.
510 changes: 275 additions & 235 deletions src/librustdoc/html/static/js/search.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion tests/rustdoc-js-std/option-type-signatures.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore-order

const FILTER_CRATE = "std";

const EXPECTED = [
Expand Down Expand Up @@ -36,8 +38,9 @@ const EXPECTED = [
],
},
{
'query': 'option<t>, option<u> -> option<t, u>',
'query': 'option<t>, option<u> -> option<t>',
'others': [
{ 'path': 'std::option::Option', 'name': 'and' },
{ 'path': 'std::option::Option', 'name': 'zip' },
],
},
Expand Down
22 changes: 22 additions & 0 deletions tests/rustdoc-js-std/vec-type-signatures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ignore-order

const FILTER_CRATE = "std";

const EXPECTED = [
{
'query': 'vec::intoiter<T> -> [T]',
'others': [
{ 'path': 'std::vec::IntoIter', 'name': 'as_slice' },
{ 'path': 'std::vec::IntoIter', 'name': 'as_mut_slice' },
{ 'path': 'std::vec::IntoIter', 'name': 'next_chunk' },
],
},
{
'query': 'vec::intoiter<T> -> []',
'others': [
{ 'path': 'std::vec::IntoIter', 'name': 'as_slice' },
{ 'path': 'std::vec::IntoIter', 'name': 'as_mut_slice' },
{ 'path': 'std::vec::IntoIter', 'name': 'next_chunk' },
],
},
];
1 change: 1 addition & 0 deletions tests/rustdoc-js/generics-match-ambiguity.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const EXPECTED = [
{ 'path': 'generics_match_ambiguity', 'name': 'baac' },
{ 'path': 'generics_match_ambiguity', 'name': 'baaf' },
{ 'path': 'generics_match_ambiguity', 'name': 'baag' },
{ 'path': 'generics_match_ambiguity', 'name': 'baah' },
],
},
{
Expand Down
38 changes: 38 additions & 0 deletions tests/rustdoc-js/generics-unbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// exact-check

const EXPECTED = [
{
'query': 'Inside<T> -> Out1<T>',
'others': [
{ 'path': 'generics_unbox', 'name': 'alpha' },
],
},
{
'query': 'Inside<T> -> Out3<T>',
'others': [
{ 'path': 'generics_unbox', 'name': 'beta' },
{ 'path': 'generics_unbox', 'name': 'gamma' },
],
},
{
'query': 'Inside<T> -> Out4<T>',
'others': [
{ 'path': 'generics_unbox', 'name': 'beta' },
{ 'path': 'generics_unbox', 'name': 'gamma' },
],
},
{
'query': 'Inside<T> -> Out3<U, T>',
'others': [
{ 'path': 'generics_unbox', 'name': 'beta' },
{ 'path': 'generics_unbox', 'name': 'gamma' },
],
},
{
'query': 'Inside<T> -> Out4<U, T>',
'others': [
{ 'path': 'generics_unbox', 'name': 'beta' },
{ 'path': 'generics_unbox', 'name': 'gamma' },
],
},
];
36 changes: 36 additions & 0 deletions tests/rustdoc-js/generics-unbox.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pub struct Out<A, B = ()> {
a: A,
b: B,
}

pub struct Out1<A, const N: usize> {
a: [A; N],
}

pub struct Out2<A, const N: usize> {
a: [A; N],
}

pub struct Out3<A, B> {
a: A,
b: B,
}

pub struct Out4<A, B> {
a: A,
b: B,
}

pub struct Inside<T>(T);

pub fn alpha<const N: usize, T>(_: Inside<T>) -> Out<Out1<T, N>, Out2<T, N>> {
loop {}
}

pub fn beta<T, U>(_: Inside<T>) -> Out<Out3<T, U>, Out4<U, T>> {
loop {}
}

pub fn gamma<T, U>(_: Inside<T>) -> Out<Out3<U, T>, Out4<T, U>> {
loop {}
}

0 comments on commit 269cb57

Please sign in to comment.