@@ -26,6 +26,8 @@ For space savings, it's also written without newlines or spaces.
26
26
"q" : [[0 , " crate_name" ]],
27
27
// parent type
28
28
"i" : [2 , 0 ],
29
+ // type dictionary
30
+ "p" : [[1 , " i32" ], [1 , " str" ], [5 , " Data" , 0 ]],
29
31
// function signature
30
32
"f" : " {{gb}{d}}`" , // [[3, 1], [2]]
31
33
// impl disambiguator
@@ -34,12 +36,12 @@ For space savings, it's also written without newlines or spaces.
34
36
"c" : " OjAAAAAAAAA=" , // empty bitmap
35
37
// empty description flag
36
38
"e" : " OjAAAAAAAAA=" , // empty bitmap
37
- // type dictionary
38
- "p" : [[1 , " i32" ], [1 , " str" ], [5 , " crate_name::Data" ]],
39
39
// aliases
40
40
"a" : [[" get_name" , 0 ]],
41
41
// description shards
42
42
"D" : " g" , // 3
43
+ // inlined re-exports
44
+ "r" : [],
43
45
}]
44
46
]
45
47
```
@@ -355,6 +357,74 @@ The bloom filter checks none of these things,
355
357
and, on top of that, can have false positives.
356
358
But it's fast and uses very little memory, so the bloom filter helps.
357
359
360
+ ## Re-exports
361
+
362
+ [ Re-export inlining] allows the same item to be found by multiple names.
363
+ Search supports this by giving the same item multiple entries and tracking a canonical path
364
+ for any items where that differs from the given path.
365
+
366
+ For example, this sample index has a single struct exported from two paths:
367
+
368
+ ``` json
369
+ [
370
+ [ " crate_name" , {
371
+ "doc" : " Documentation" ,
372
+ "n" : [" Data" , " Data" ],
373
+ "t" : " FF" ,
374
+ "d" : [" The data struct" , " The data struct" ],
375
+ "q" : [[0 , " crate_name" ], [1 , " crate_name::submodule" ]],
376
+ "i" : [0 , 0 ],
377
+ "p" : [],
378
+ "f" : " ``" ,
379
+ "b" : [],
380
+ "c" : [],
381
+ "a" : [],
382
+ "r" : [[0 , 1 ]],
383
+ }]
384
+ ]
385
+ ```
386
+
387
+ The important part of this example is the ` r ` array,
388
+ which indicates that path entry 1 in the ` q ` array is
389
+ the canonical path for item 0.
390
+ That is, ` crate_name::Data ` has a canonical path of ` crate_name::submodule::Data ` .
391
+
392
+ This might sound like a strange design, since it has the duplicate data.
393
+ It's done that way because inlining can happen across crates,
394
+ which are compiled separately and might not all be present in the docs.
395
+
396
+ ``` json
397
+ [
398
+ [ " crate_name" , ... ],
399
+ [ " crate_name_2" , { "q" : [[0 , " crate_name::submodule" ], [5 , " core::option" ]], ... }]
400
+ ]
401
+ ```
402
+
403
+ In the above example, a canonical path actually comes from a dependency,
404
+ and another one comes from an inlined standard library item:
405
+ the canonical path isn't even in the index!
406
+ The canonical path might also be private.
407
+ In either case, it's never shown to the user, and is only used for deduplication.
408
+
409
+ Associated types, like methods, store them differently.
410
+ These types are connected with an entry in ` p ` (their "parent")
411
+ and each one has an optional third tuple element:
412
+
413
+ "p": [[5, "Data", 0, 1]]
414
+
415
+ That's:
416
+
417
+ - 5: It's a struct
418
+ - "Data": Its name
419
+ - 0: Its display path, "crate_name"
420
+ - 1: Its canonical path, "crate_name::submodule"
421
+
422
+ In both cases, the canonical path might not be public at all,
423
+ or it might be from another crate that isn't in the docs,
424
+ so it's never shown to the user, but is used for deduplication.
425
+
426
+ [ Re-export inlining ] : https://doc.rust-lang.org/nightly/rustdoc/write-documentation/re-exports.html
427
+
358
428
## Testing the search engine
359
429
360
430
While the generated UI is tested using ` rustdoc-gui ` tests, the
@@ -453,4 +523,4 @@ const EXPECTED = [
453
523
returned: [],
454
524
},
455
525
]
456
- ```
526
+ ```
0 commit comments