about summary refs log tree commit diff
path: root/src/librustdoc/html/render/write_shared
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-06-05 18:42:54 -0500
committerbinarycat <binarycat@envs.net>2025-06-16 20:22:24 -0500
commit00c104225fad5d3eb27dc37719d9b6c26844c389 (patch)
tree42727f2fcbc138cb483a4ce5787014d2329f6a03 /src/librustdoc/html/render/write_shared
parent3bc767e1a215c4bf8f099b32e84edb85780591b1 (diff)
rustdoc: make srcIndex no longer a global variable
this is one-time initialization data, it can just
be a function parameter.

we also move the json parsing into createSrcSidebar
to save a few bytes.
Diffstat (limited to 'src/librustdoc/html/render/write_shared')
-rw-r--r--src/librustdoc/html/render/write_shared/tests.rs18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/librustdoc/html/render/write_shared/tests.rs b/src/librustdoc/html/render/write_shared/tests.rs
index a235f1d3724..6f185e85345 100644
--- a/src/librustdoc/html/render/write_shared/tests.rs
+++ b/src/librustdoc/html/render/write_shared/tests.rs
@@ -22,23 +22,11 @@ fn but_last_line(s: &str) -> &str {
 #[test]
 fn sources_template() {
     let mut template = SourcesPart::blank();
-    assert_eq!(
-        but_last_line(&template.to_string()),
-        r"var srcIndex = new Map(JSON.parse('[]'));
-createSrcSidebar();"
-    );
+    assert_eq!(but_last_line(&template.to_string()), r"createSrcSidebar('[]');");
     template.append(EscapedJson::from(OrderedJson::serialize("u").unwrap()).to_string());
-    assert_eq!(
-        but_last_line(&template.to_string()),
-        r#"var srcIndex = new Map(JSON.parse('["u"]'));
-createSrcSidebar();"#
-    );
+    assert_eq!(but_last_line(&template.to_string()), r#"createSrcSidebar('["u"]');"#);
     template.append(EscapedJson::from(OrderedJson::serialize("v").unwrap()).to_string());
-    assert_eq!(
-        but_last_line(&template.to_string()),
-        r#"var srcIndex = new Map(JSON.parse('["u","v"]'));
-createSrcSidebar();"#
-    );
+    assert_eq!(but_last_line(&template.to_string()), r#"createSrcSidebar('["u","v"]');"#);
 }
 
 #[test]