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.
This commit is contained in:
parent
de686cbc65
commit
09c8fd35ac
@ -297,7 +297,10 @@ fn add_path(self: &Rc<Self>, path: &Path) {
|
|||||||
.replace("\\\"", "\\\\\"")
|
.replace("\\\"", "\\\\\"")
|
||||||
));
|
));
|
||||||
all_sources.sort();
|
all_sources.sort();
|
||||||
let mut v = String::from("const srcIndex = new Map(JSON.parse('[\\\n");
|
// This needs to be `var`, not `const`.
|
||||||
|
// This variable needs declared in the current global scope so that if
|
||||||
|
// src-script.js loads first, it can pick it up.
|
||||||
|
let mut v = String::from("var srcIndex = new Map(JSON.parse('[\\\n");
|
||||||
v.push_str(&all_sources.join(",\\\n"));
|
v.push_str(&all_sources.join(",\\\n"));
|
||||||
v.push_str("\\\n]'));\ncreateSrcSidebar();\n");
|
v.push_str("\\\n]'));\ncreateSrcSidebar();\n");
|
||||||
Ok(v.into_bytes())
|
Ok(v.into_bytes())
|
||||||
@ -317,7 +320,10 @@ fn add_path(self: &Rc<Self>, path: &Path) {
|
|||||||
// with rustdoc running in parallel.
|
// with rustdoc running in parallel.
|
||||||
all_indexes.sort();
|
all_indexes.sort();
|
||||||
write_invocation_specific("search-index.js", &|| {
|
write_invocation_specific("search-index.js", &|| {
|
||||||
let mut v = String::from("const searchIndex = new Map(JSON.parse('[\\\n");
|
// This needs to be `var`, not `const`.
|
||||||
|
// This variable needs declared in the current global scope so that if
|
||||||
|
// search.js loads first, it can pick it up.
|
||||||
|
let mut v = String::from("var searchIndex = new Map(JSON.parse('[\\\n");
|
||||||
v.push_str(&all_indexes.join(",\\\n"));
|
v.push_str(&all_indexes.join(",\\\n"));
|
||||||
v.push_str(
|
v.push_str(
|
||||||
r#"\
|
r#"\
|
||||||
|
Loading…
Reference in New Issue
Block a user