about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-04-26 13:22:28 +0200
committerGitHub <noreply@github.com>2022-04-26 13:22:28 +0200
commit52fefb0454405763dc0b8ebe9f1fb927df3ca2d3 (patch)
tree6d3471f707074ff91b7eab410919e0000c8ca92c /src/tools
parent2b8bf0d530f8be971264b2430f40217433568968 (diff)
parent0233abebc85d336e92849ae7bca1fd8c1ef4f097 (diff)
downloadrust-52fefb0454405763dc0b8ebe9f1fb927df3ca2d3.tar.gz
rust-52fefb0454405763dc0b8ebe9f1fb927df3ca2d3.zip
Rollup merge of #96361 - GuillaumeGomez:es6, r=notriddle
Switch JS code to ES6

Considering it's already quite big, I'll do the remaining files in another PR.

Part of #93058.

r? ``@notriddle``
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/rustdoc-js/tester.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js
index 17362338355..98d0f5dc656 100644
--- a/src/tools/rustdoc-js/tester.js
+++ b/src/tools/rustdoc-js/tester.js
@@ -85,8 +85,11 @@ function extractFunction(content, functionName) {
 }
 
 // Stupid function extractor for array.
-function extractArrayVariable(content, arrayName) {
-    var splitter = "var " + arrayName;
+function extractArrayVariable(content, arrayName, kind) {
+    if (typeof kind === "undefined") {
+        kind = "let ";
+    }
+    var splitter = kind + arrayName;
     while (true) {
         var start = content.indexOf(splitter);
         if (start === -1) {
@@ -126,12 +129,18 @@ function extractArrayVariable(content, arrayName) {
         }
         content = content.slice(start + 1);
     }
+    if (kind === "let ") {
+        return extractArrayVariable(content, arrayName, "const ");
+    }
     return null;
 }
 
 // Stupid function extractor for variable.
-function extractVariable(content, varName) {
-    var splitter = "var " + varName;
+function extractVariable(content, varName, kind) {
+    if (typeof kind === "undefined") {
+        kind = "let ";
+    }
+    var splitter = kind + varName;
     while (true) {
         var start = content.indexOf(splitter);
         if (start === -1) {
@@ -162,6 +171,9 @@ function extractVariable(content, varName) {
         }
         content = content.slice(start + 1);
     }
+    if (kind === "let ") {
+        return extractVariable(content, varName, "const ");
+    }
     return null;
 }