Skip to content

Commit

Permalink
Compat librustdoc corpus format change
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Oct 15, 2024
1 parent 17181e6 commit 60d27b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/search/docs/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,8 @@ export default class LibrustDocSearch {
// An array of [(Number) item index, (Number) path index]
// Used to de-duplicate inlined and re-exported stuff
const itemReexports = new Map(crateCorpus.r);
// librustdoc changed crateCorpus.i from array to string, we need some compatible code.
const newCorpusFormat = typeof crateCorpus.i === "string";
// an array of (Number) the parent path index + 1 to `paths`, or 0 if none
const itemParentIdxDecoder = new VlqHexDecoder(crateCorpus.i, noop => noop);
// a map Number, string for impl disambiguators
Expand Down Expand Up @@ -1670,11 +1672,11 @@ export default class LibrustDocSearch {
}
// This object should have exactly the same set of fields as the "crateRow"
// object defined above.
const itemParentIdx = itemParentIdxDecoder.next();
const itemParentIdx = newCorpusFormat ? itemParentIdxDecoder.next(): crateCorpus.i[i];
const row = {
crate,
ty: itemTypes.charCodeAt(i) - 65, // 65 = "A"
name,
name: newCorpusFormat? name : itemNames[i],
path,
descShard,
descIndex,
Expand Down

0 comments on commit 60d27b2

Please sign in to comment.