Skip to content

Commit d6a1504

Browse files
authored
Unrolled build for #148563
Rollup merge of #148563 - notriddle:index-typedata-bug, r=GuillaumeGomez rustdoc-search: remove broken index special case Fixes #148431
2 parents c5e283b + c8b2a9a commit d6a1504

File tree

4 files changed

+71
-21
lines changed

4 files changed

+71
-21
lines changed

src/librustdoc/html/render/search_index.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,28 +1051,21 @@ impl Serialize for TypeData {
10511051
where
10521052
S: Serializer,
10531053
{
1054-
if self.search_unbox
1055-
|| !self.inverted_function_inputs_index.is_empty()
1056-
|| !self.inverted_function_output_index.is_empty()
1057-
{
1058-
let mut seq = serializer.serialize_seq(None)?;
1059-
let mut buf = Vec::new();
1060-
encode::write_postings_to_string(&self.inverted_function_inputs_index, &mut buf);
1061-
let mut serialized_result = Vec::new();
1062-
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
1063-
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
1064-
buf.clear();
1065-
serialized_result.clear();
1066-
encode::write_postings_to_string(&self.inverted_function_output_index, &mut buf);
1067-
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
1068-
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
1069-
if self.search_unbox {
1070-
seq.serialize_element(&1)?;
1071-
}
1072-
seq.end()
1073-
} else {
1074-
None::<()>.serialize(serializer)
1054+
let mut seq = serializer.serialize_seq(None)?;
1055+
let mut buf = Vec::new();
1056+
encode::write_postings_to_string(&self.inverted_function_inputs_index, &mut buf);
1057+
let mut serialized_result = Vec::new();
1058+
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
1059+
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
1060+
buf.clear();
1061+
serialized_result.clear();
1062+
encode::write_postings_to_string(&self.inverted_function_output_index, &mut buf);
1063+
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
1064+
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
1065+
if self.search_unbox {
1066+
seq.serialize_element(&1)?;
10751067
}
1068+
seq.end()
10761069
}
10771070
}
10781071

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// https://github.com/rust-lang/rust/issues/148431
2+
3+
// This test is designed to hit a case where, thanks to the
4+
// recursion limit, the where clause gets generated, but not
5+
// used, because we run out of fuel.
6+
//
7+
// This results in a reverse index with nothing in it, which
8+
// used to crash when we parsed it.
9+
pub fn foobar1<A: T1<B>, B: T2<C>, C: T3<D>, D: T4<A>>(a: A) {}
10+
11+
pub trait T1<T: ?Sized> {}
12+
pub trait T2<T: ?Sized> {}
13+
pub trait T3<T: ?Sized> {}
14+
pub trait T4<T: ?Sized> {}
15+
16+
// foobar1 is the version that worked at the time this test was written
17+
// the rest are here to try to make the test at least a little more
18+
// robust, in the sense that it actually tests the code and isn't magically
19+
// fixed by the recursion limit changing
20+
pub fn foobar2<A: U1<B>, B: U2<C>, C: U3<D>, D: U4<E>, E: U5<A>>(a: A) {}
21+
22+
pub trait U1<T: ?Sized> {}
23+
pub trait U2<T: ?Sized> {}
24+
pub trait U3<T: ?Sized> {}
25+
pub trait U4<T: ?Sized> {}
26+
pub trait U5<T: ?Sized> {}
27+
28+
pub fn foobar3<A: V1<B>, B: V2<C>, C: V3<D>, D: V4<E>, E: V5<F>, F: V6<A>>(a: A) {}
29+
30+
pub trait V1<T: ?Sized> {}
31+
pub trait V2<T: ?Sized> {}
32+
pub trait V3<T: ?Sized> {}
33+
pub trait V4<T: ?Sized> {}
34+
pub trait V5<T: ?Sized> {}
35+
pub trait V6<T: ?Sized> {}
36+
37+
pub fn foobar4<A: W1<B>, B: W2<C>, C: W3<A>>(a: A) {}
38+
39+
pub trait W1<T: ?Sized> {}
40+
pub trait W2<T: ?Sized> {}
41+
pub trait W3<T: ?Sized> {}

tests/rustdoc-js/empty-type.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const EXPECTED = [
2+
{
3+
query: 'baz',
4+
others: [
5+
{ name: 'baz' }
6+
],
7+
},
8+
];

tests/rustdoc-js/empty-type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ aux-crate:emptytype=emptytype.rs
2+
//@ compile-flags: --extern emptytype
3+
//@ aux-build:emptytype.rs
4+
//@ build-aux-docs
5+
6+
extern crate emptytype;
7+
8+
pub fn baz() {}

0 commit comments

Comments
 (0)