You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows the public `rustdoc-types` crate to expose this feature
easily and allows consumers of the crate to get the performance
advantages from doing so.
The reasoning for this was discussed on [Zulip][1]
Changes:
- Make `rustc-hash` optional but default to including it
- Rename all occurrences of `FxHashMap` to `HashMap`.
- Feature gate the import and rename the imported `FxHashMap` to
`HashMap`
- Introduce a type alias `FxHashMap` which resolves to the currently
used `HashMap` (`rustc_hash::FxHashMap` or
`std::collections::HashMap`) for use in `src/librustdoc`.
[1]: https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/rustc-hash.20and.20performance.20of.20rustdoc-types
Copy file name to clipboardExpand all lines: src/rustdoc-json-types/lib.rs
+10-5
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,16 @@
3
3
//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`]
4
4
//! struct is the root of the JSON blob and all other items are contained within.
5
5
6
+
#[cfg(not(feature = "rustc-hash"))]
7
+
use std::collections::HashMap;
6
8
use std::path::PathBuf;
7
9
8
-
pubuse rustc_hash::FxHashMap;
10
+
#[cfg(feature = "rustc-hash")]
11
+
use rustc_hash::FxHashMapasHashMap;
9
12
use serde::{Deserialize,Serialize};
10
13
14
+
pubtypeFxHashMap<K,V> = HashMap<K,V>;// re-export for use in src/librustdoc
15
+
11
16
/// The version of JSON output that this crate represents.
12
17
///
13
18
/// This integer is incremented with every breaking change to the API,
@@ -30,11 +35,11 @@ pub struct Crate {
30
35
pubincludes_private:bool,
31
36
/// A collection of all items in the local crate as well as some external traits and their
32
37
/// items that are referenced locally.
33
-
pubindex:FxHashMap<Id,Item>,
38
+
pubindex:HashMap<Id,Item>,
34
39
/// Maps IDs to fully qualified paths and other info helpful for generating links.
35
-
pubpaths:FxHashMap<Id,ItemSummary>,
40
+
pubpaths:HashMap<Id,ItemSummary>,
36
41
/// Maps `crate_id` of items to a crate name and html_root_url if it exists.
37
-
pubexternal_crates:FxHashMap<u32,ExternalCrate>,
42
+
pubexternal_crates:HashMap<u32,ExternalCrate>,
38
43
/// A single version number to be used in the future when making backwards incompatible changes
39
44
/// to the JSON output.
40
45
pubformat_version:u32,
@@ -95,7 +100,7 @@ pub struct Item {
95
100
/// Some("") if there is some documentation but it is empty (EG `#[doc = ""]`).
96
101
pubdocs:Option<String>,
97
102
/// This mapping resolves [intra-doc links](https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md) from the docstring to their IDs
98
-
publinks:FxHashMap<String,Id>,
103
+
publinks:HashMap<String,Id>,
99
104
/// Stringified versions of the attributes on this item (e.g. `"#[inline]"`)
100
105
pubattrs:Vec<String>,
101
106
/// Information about the item’s deprecation, if present.
0 commit comments