rustdoc-search: remove broken index special case

This commit is contained in:
Michael Howell 2025-11-05 23:37:51 -07:00
parent 6e41e61977
commit c8b2a9af2b
4 changed files with 71 additions and 21 deletions

View file

@ -1051,28 +1051,21 @@ impl Serialize for TypeData {
where
S: Serializer,
{
if self.search_unbox
|| !self.inverted_function_inputs_index.is_empty()
|| !self.inverted_function_output_index.is_empty()
{
let mut seq = serializer.serialize_seq(None)?;
let mut buf = Vec::new();
encode::write_postings_to_string(&self.inverted_function_inputs_index, &mut buf);
let mut serialized_result = Vec::new();
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
buf.clear();
serialized_result.clear();
encode::write_postings_to_string(&self.inverted_function_output_index, &mut buf);
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
if self.search_unbox {
seq.serialize_element(&1)?;
}
seq.end()
} else {
None::<()>.serialize(serializer)
let mut seq = serializer.serialize_seq(None)?;
let mut buf = Vec::new();
encode::write_postings_to_string(&self.inverted_function_inputs_index, &mut buf);
let mut serialized_result = Vec::new();
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
buf.clear();
serialized_result.clear();
encode::write_postings_to_string(&self.inverted_function_output_index, &mut buf);
stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result);
seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?;
if self.search_unbox {
seq.serialize_element(&1)?;
}
seq.end()
}
}

View file

@ -0,0 +1,41 @@
// https://github.com/rust-lang/rust/issues/148431
// This test is designed to hit a case where, thanks to the
// recursion limit, the where clause gets generated, but not
// used, because we run out of fuel.
//
// This results in a reverse index with nothing in it, which
// used to crash when we parsed it.
pub fn foobar1<A: T1<B>, B: T2<C>, C: T3<D>, D: T4<A>>(a: A) {}
pub trait T1<T: ?Sized> {}
pub trait T2<T: ?Sized> {}
pub trait T3<T: ?Sized> {}
pub trait T4<T: ?Sized> {}
// foobar1 is the version that worked at the time this test was written
// the rest are here to try to make the test at least a little more
// robust, in the sense that it actually tests the code and isn't magically
// fixed by the recursion limit changing
pub fn foobar2<A: U1<B>, B: U2<C>, C: U3<D>, D: U4<E>, E: U5<A>>(a: A) {}
pub trait U1<T: ?Sized> {}
pub trait U2<T: ?Sized> {}
pub trait U3<T: ?Sized> {}
pub trait U4<T: ?Sized> {}
pub trait U5<T: ?Sized> {}
pub fn foobar3<A: V1<B>, B: V2<C>, C: V3<D>, D: V4<E>, E: V5<F>, F: V6<A>>(a: A) {}
pub trait V1<T: ?Sized> {}
pub trait V2<T: ?Sized> {}
pub trait V3<T: ?Sized> {}
pub trait V4<T: ?Sized> {}
pub trait V5<T: ?Sized> {}
pub trait V6<T: ?Sized> {}
pub fn foobar4<A: W1<B>, B: W2<C>, C: W3<A>>(a: A) {}
pub trait W1<T: ?Sized> {}
pub trait W2<T: ?Sized> {}
pub trait W3<T: ?Sized> {}

View file

@ -0,0 +1,8 @@
const EXPECTED = [
{
query: 'baz',
others: [
{ name: 'baz' }
],
},
];

View file

@ -0,0 +1,8 @@
//@ aux-crate:emptytype=emptytype.rs
//@ compile-flags: --extern emptytype
//@ aux-build:emptytype.rs
//@ build-aux-docs
extern crate emptytype;
pub fn baz() {}