Skip to content

Commit

Permalink
rustdoc-search: fix a race condition in search index loading
Browse files Browse the repository at this point in the history
`var` declare it in the global scope, and `const` does not.
It needs to be declared in global scope.
  • Loading branch information
notriddle committed Dec 15, 2023
1 parent de686cb commit 9e952b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub(super) fn write_shared(
.replace("\\\"", "\\\\\"")
));
all_sources.sort();
let mut v = String::from("const srcIndex = new Map(JSON.parse('[\\\n");
let mut v = String::from("var srcIndex = new Map(JSON.parse('[\\\n");
v.push_str(&all_sources.join(",\\\n"));
v.push_str("\\\n]'));\ncreateSrcSidebar();\n");
Ok(v.into_bytes())
Expand All @@ -317,7 +317,7 @@ pub(super) fn write_shared(
// with rustdoc running in parallel.
all_indexes.sort();
write_invocation_specific("search-index.js", &|| {
let mut v = String::from("const searchIndex = new Map(JSON.parse('[\\\n");
let mut v = String::from("var searchIndex = new Map(JSON.parse('[\\\n");
v.push_str(&all_indexes.join(",\\\n"));
v.push_str(
r#"\
Expand Down

0 comments on commit 9e952b7

Please sign in to comment.