Skip to content

Commit 9e952b7

Browse files
committed
rustdoc-search: fix a race condition in search index loading
`var` declare it in the global scope, and `const` does not. It needs to be declared in global scope.
1 parent de686cb commit 9e952b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/librustdoc/html/render/write_shared.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ pub(super) fn write_shared(
297297
.replace("\\\"", "\\\\\"")
298298
));
299299
all_sources.sort();
300-
let mut v = String::from("const srcIndex = new Map(JSON.parse('[\\\n");
300+
let mut v = String::from("var srcIndex = new Map(JSON.parse('[\\\n");
301301
v.push_str(&all_sources.join(",\\\n"));
302302
v.push_str("\\\n]'));\ncreateSrcSidebar();\n");
303303
Ok(v.into_bytes())
@@ -317,7 +317,7 @@ pub(super) fn write_shared(
317317
// with rustdoc running in parallel.
318318
all_indexes.sort();
319319
write_invocation_specific("search-index.js", &|| {
320-
let mut v = String::from("const searchIndex = new Map(JSON.parse('[\\\n");
320+
let mut v = String::from("var searchIndex = new Map(JSON.parse('[\\\n");
321321
v.push_str(&all_indexes.join(",\\\n"));
322322
v.push_str(
323323
r#"\

0 commit comments

Comments
 (0)