about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-03-04 00:27:27 -0600
committerbinarycat <binarycat@envs.net>2025-03-04 00:27:27 -0600
commit2f9ea8a55ad6397bae7d97f653bbe02915017f03 (patch)
treebc743ec2be19f1195f5ac20023da94199bdbf4f0
parenta8c0b3bfff36c5b7dbd429891b7fd2093e25a9ad (diff)
downloadrust-2f9ea8a55ad6397bae7d97f653bbe02915017f03.tar.gz
rust-2f9ea8a55ad6397bae7d97f653bbe02915017f03.zip
rustdoc search: give buildTypeMapIndex a conditional return type
we encode "if the argument is a non-empty string,
this will never return null" into the type signature.
-rw-r--r--src/librustdoc/html/static/js/search.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 4073bb389c0..bd0dab97f01 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -1477,73 +1477,61 @@ class DocSearch {
          * Special type name IDs for searching by array.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfArray = this.buildTypeMapIndex("array");
         /**
          * Special type name IDs for searching by slice.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfSlice = this.buildTypeMapIndex("slice");
         /**
          * Special type name IDs for searching by both array and slice (`[]` syntax).
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfArrayOrSlice = this.buildTypeMapIndex("[]");
         /**
          * Special type name IDs for searching by tuple.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfTuple = this.buildTypeMapIndex("tuple");
         /**
          * Special type name IDs for searching by unit.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfUnit = this.buildTypeMapIndex("unit");
         /**
          * Special type name IDs for searching by both tuple and unit (`()` syntax).
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfTupleOrUnit = this.buildTypeMapIndex("()");
         /**
          * Special type name IDs for searching `fn`.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfFn = this.buildTypeMapIndex("fn");
         /**
          * Special type name IDs for searching `fnmut`.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfFnMut = this.buildTypeMapIndex("fnmut");
         /**
          * Special type name IDs for searching `fnonce`.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfFnOnce = this.buildTypeMapIndex("fnonce");
         /**
          * Special type name IDs for searching higher order functions (`->` syntax).
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfHof = this.buildTypeMapIndex("->");
         /**
          * Special type name IDs the output assoc type.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfOutput = this.buildTypeMapIndex("output", true);
         /**
          * Special type name IDs for searching by reference.
          * @type {number}
          */
-        // @ts-expect-error
         this.typeNameIdOfReference = this.buildTypeMapIndex("reference");
 
         /**
@@ -1596,11 +1584,17 @@ class DocSearch {
      * This is effectively string interning, so that function matching can be
      * done more quickly. Two types with the same name but different item kinds
      * get the same ID.
-     *
-     * @param {string} name
+	 *
+	 * @template T extends string
+	 * @overload
+     * @param {T} name
      * @param {boolean=} isAssocType - True if this is an assoc type
-     *
-     * @returns {number?}
+     * @returns {T extends "" ? null : number}
+	 *
+	 * @param {string} name
+     * @param {boolean=} isAssocType
+     * @returns {number | null}
+	 * 
      */
     buildTypeMapIndex(name, isAssocType) {
         if (name === "" || name === null) {