]>
Commit | Line | Data |
---|---|---|
a2a8927a XL |
1 | // This file contains type definitions that are processed by the Closure Compiler but are |
2 | // not put into the JavaScript we include as part of the documentation. It is used for | |
3 | // type checking. See README.md in this directory for more info. | |
4 | ||
5 | /* eslint-disable */ | |
04454e1e | 6 | let searchState; |
a2a8927a XL |
7 | function initSearch(searchIndex){} |
8 | ||
9 | /** | |
10 | * @typedef {{ | |
04454e1e | 11 | * name: string, |
781aab86 | 12 | * id: integer|null, |
04454e1e FG |
13 | * fullPath: Array<string>, |
14 | * pathWithoutLast: Array<string>, | |
15 | * pathLast: string, | |
16 | * generics: Array<QueryElement>, | |
4b012472 | 17 | * bindings: Map<integer, Array<QueryElement>>, |
a2a8927a XL |
18 | * }} |
19 | */ | |
04454e1e FG |
20 | let QueryElement; |
21 | ||
22 | /** | |
23 | * @typedef {{ | |
24 | * pos: number, | |
25 | * totalElems: number, | |
26 | * typeFilter: (null|string), | |
27 | * userQuery: string, | |
4b012472 | 28 | * isInBinding: (null|string), |
04454e1e FG |
29 | * }} |
30 | */ | |
31 | let ParserState; | |
32 | ||
33 | /** | |
34 | * @typedef {{ | |
35 | * original: string, | |
36 | * userQuery: string, | |
37 | * typeFilter: number, | |
38 | * elems: Array<QueryElement>, | |
39 | * args: Array<QueryElement>, | |
40 | * returned: Array<QueryElement>, | |
41 | * foundElems: number, | |
781aab86 | 42 | * totalElems: number, |
49aad941 FG |
43 | * literalSearch: boolean, |
44 | * corrections: Array<{from: string, to: integer}>, | |
4b012472 | 45 | * typeFingerprint: Uint32Array, |
04454e1e FG |
46 | * }} |
47 | */ | |
48 | let ParsedQuery; | |
a2a8927a XL |
49 | |
50 | /** | |
51 | * @typedef {{ | |
52 | * crate: string, | |
53 | * desc: string, | |
54 | * id: number, | |
55 | * name: string, | |
56 | * normalizedName: string, | |
57 | * parent: (Object|null|undefined), | |
58 | * path: string, | |
59 | * ty: (Number|null|number), | |
fe692bf9 | 60 | * type: FunctionSearchType? |
a2a8927a XL |
61 | * }} |
62 | */ | |
04454e1e FG |
63 | let Row; |
64 | ||
65 | /** | |
66 | * @typedef {{ | |
67 | * in_args: Array<Object>, | |
68 | * returned: Array<Object>, | |
69 | * others: Array<Object>, | |
70 | * query: ParsedQuery, | |
71 | * }} | |
72 | */ | |
73 | let ResultsTable; | |
74 | ||
353b0b11 FG |
75 | /** |
76 | * @typedef {Map<String, ResultObject>} | |
77 | */ | |
78 | let Results; | |
79 | ||
04454e1e FG |
80 | /** |
81 | * @typedef {{ | |
82 | * desc: string, | |
83 | * displayPath: string, | |
84 | * fullPath: string, | |
85 | * href: string, | |
86 | * id: number, | |
87 | * lev: number, | |
88 | * name: string, | |
89 | * normalizedName: string, | |
90 | * parent: (Object|undefined), | |
91 | * path: string, | |
92 | * ty: number, | |
93 | * }} | |
94 | */ | |
353b0b11 | 95 | let ResultObject; |
064997fb FG |
96 | |
97 | /** | |
98 | * A pair of [inputs, outputs], or 0 for null. This is stored in the search index. | |
99 | * The JavaScript deserializes this into FunctionSearchType. | |
100 | * | |
101 | * Numeric IDs are *ONE-indexed* into the paths array (`p`). Zero is used as a sentinel for `null` | |
102 | * because `null` is four bytes while `0` is one byte. | |
103 | * | |
104 | * An input or output can be encoded as just a number if there is only one of them, AND | |
105 | * it has no generics. The no generics rule exists to avoid ambiguity: imagine if you had | |
106 | * a function with a single output, and that output had a single generic: | |
107 | * | |
108 | * fn something() -> Result<usize, usize> | |
109 | * | |
781aab86 | 110 | * If output was allowed to be any RawFunctionType, it would look like thi |
064997fb FG |
111 | * |
112 | * [[], [50, [3, 3]]] | |
113 | * | |
114 | * The problem is that the above output could be interpreted as either a type with ID 50 and two | |
115 | * generics, or it could be interpreted as a pair of types, the first one with ID 50 and the second | |
116 | * with ID 3 and a single generic parameter that is also ID 3. We avoid this ambiguity by choosing | |
117 | * in favor of the pair of types interpretation. This is why the `(number|Array<RawFunctionType>)` | |
118 | * is used instead of `(RawFunctionType|Array<RawFunctionType>)`. | |
119 | * | |
781aab86 FG |
120 | * The output can be skipped if it's actually unit and there's no type constraints. If thi |
121 | * function accepts constrained generics, then the output will be unconditionally emitted, and | |
122 | * after it will come a list of trait constraints. The position of the item in the list will | |
123 | * determine which type parameter it is. For example: | |
124 | * | |
125 | * [1, 2, 3, 4, 5] | |
126 | * ^ ^ ^ ^ ^ | |
127 | * | | | | - generic parameter (-3) of trait 5 | |
128 | * | | | - generic parameter (-2) of trait 4 | |
129 | * | | - generic parameter (-1) of trait 3 | |
130 | * | - this function returns a single value (type 2) | |
131 | * - this function takes a single input parameter (type 1) | |
132 | * | |
133 | * Or, for a less contrived version: | |
134 | * | |
135 | * [[[4, -1], 3], [[5, -1]], 11] | |
136 | * -^^^^^^^---- ^^^^^^^ ^^ | |
137 | * | | | - generic parameter, roughly `where -1: 11` | |
138 | * | | | since -1 is the type parameter and 11 the trait | |
139 | * | | - function output 5<-1> | |
140 | * | - the overall function signature is something like | |
141 | * | `fn(4<-1>, 3) -> 5<-1> where -1: 11` | |
142 | * - function input, corresponds roughly to 4<-1> | |
143 | * 4 is an index into the `p` array for a type | |
144 | * -1 is the generic parameter, given by 11 | |
145 | * | |
146 | * If a generic parameter has multiple trait constraints, it gets wrapped in an array, just like | |
147 | * function inputs and outputs: | |
148 | * | |
149 | * [-1, -1, [4, 3]] | |
150 | * ^^^^^^ where -1: 4 + 3 | |
151 | * | |
152 | * If a generic parameter's trait constraint has generic parameters, it gets wrapped in the array | |
153 | * even if only one exists. In other words, the ambiguity of `4<3>` and `4 + 3` is resolved in | |
154 | * favor of `4 + 3`: | |
155 | * | |
156 | * [-1, -1, [[4, 3]]] | |
157 | * ^^^^^^^^ where -1: 4 + 3 | |
158 | * | |
159 | * [-1, -1, [5, [4, 3]]] | |
160 | * ^^^^^^^^^^^ where -1: 5, -2: 4 + 3 | |
161 | * | |
162 | * If a generic parameter has no trait constraints (like in Rust, the `Sized` constraint i | |
163 | * implied and a fake `?Sized` constraint used to note its absence), it will be filled in with 0. | |
164 | * | |
064997fb FG |
165 | * @typedef {( |
166 | * 0 | | |
167 | * [(number|Array<RawFunctionType>)] | | |
781aab86 FG |
168 | * [(number|Array<RawFunctionType>), (number|Array<RawFunctionType>)] | |
169 | * Array<(number|Array<RawFunctionType>)> | |
064997fb FG |
170 | * )} |
171 | */ | |
172 | let RawFunctionSearchType; | |
173 | ||
174 | /** | |
175 | * A single function input or output type. This is either a single path ID, or a pair of | |
176 | * [path ID, generics]. | |
177 | * | |
178 | * Numeric IDs are *ONE-indexed* into the paths array (`p`). Zero is used as a sentinel for `null` | |
179 | * because `null` is four bytes while `0` is one byte. | |
180 | * | |
181 | * @typedef {number | [number, Array<RawFunctionType>]} | |
182 | */ | |
183 | let RawFunctionType; | |
184 | ||
185 | /** | |
186 | * @typedef {{ | |
187 | * inputs: Array<FunctionType>, | |
fe692bf9 | 188 | * output: Array<FunctionType>, |
781aab86 | 189 | * where_clause: Array<Array<FunctionType>>, |
064997fb FG |
190 | * }} |
191 | */ | |
192 | let FunctionSearchType; | |
193 | ||
194 | /** | |
195 | * @typedef {{ | |
49aad941 | 196 | * id: (null|number), |
4b012472 | 197 | * ty: number, |
064997fb | 198 | * generics: Array<FunctionType>, |
4b012472 | 199 | * bindings: Map<integer, Array<FunctionType>>, |
064997fb FG |
200 | * }} |
201 | */ | |
202 | let FunctionType; | |
c0240ec0 FG |
203 | |
204 | /** | |
205 | * The raw search data for a given crate. `n`, `t`, `d`, `i`, and `f` | |
206 | * are arrays with the same length. `q`, `a`, and `c` use a sparse | |
207 | * representation for compactness. | |
208 | * | |
209 | * `n[i]` contains the name of an item. | |
210 | * | |
211 | * `t[i]` contains the type of that item | |
212 | * (as a string of characters that represent an offset in `itemTypes`). | |
213 | * | |
214 | * `d[i]` contains the description of that item. | |
215 | * | |
216 | * `q` contains the full paths of the items. For compactness, it is a set of | |
217 | * (index, path) pairs used to create a map. If a given index `i` is | |
218 | * not present, this indicates "same as the last index present". | |
219 | * | |
220 | * `i[i]` contains an item's parent, usually a module. For compactness, | |
221 | * it is a set of indexes into the `p` array. | |
222 | * | |
223 | * `f` contains function signatures, or `0` if the item isn't a function. | |
224 | * More information on how they're encoded can be found in rustc-dev-guide | |
225 | * | |
226 | * Functions are themselves encoded as arrays. The first item is a list of | |
227 | * types representing the function's inputs, and the second list item is a list | |
228 | * of types representing the function's output. Tuples are flattened. | |
229 | * Types are also represented as arrays; the first item is an index into the `p` | |
230 | * array, while the second is a list of types representing any generic parameters. | |
231 | * | |
232 | * b[i] contains an item's impl disambiguator. This is only present if an item | |
233 | * is defined in an impl block and, the impl block's type has more than one associated | |
234 | * item with the same name. | |
235 | * | |
236 | * `a` defines aliases with an Array of pairs: [name, offset], where `offset` | |
237 | * points into the n/t/d/q/i/f arrays. | |
238 | * | |
239 | * `doc` contains the description of the crate. | |
240 | * | |
241 | * `p` is a list of path/type pairs. It is used for parents and function parameters. | |
242 | * | |
243 | * `c` is an array of item indices that are deprecated. | |
244 | * @typedef {{ | |
245 | * doc: string, | |
246 | * a: Object, | |
247 | * n: Array<string>, | |
248 | * t: String, | |
249 | * d: Array<string>, | |
250 | * q: Array<[Number, string]>, | |
251 | * i: Array<Number>, | |
252 | * f: string, | |
253 | * p: Array<Object>, | |
254 | * b: Array<[Number, String]>, | |
255 | * c: Array<Number> | |
256 | * }} | |
257 | */ | |
258 | let RawSearchIndexCrate; |