From 880d565df1590b01ba9b7b38145692069d43f4cc Mon Sep 17 00:00:00 2001 From: Jalil David Salamé Messina Date: Sun, 20 Oct 2024 18:28:14 +0200 Subject: fix(rustdoc-json-types): document rustc-hash feature The `rustc-hash` feature is publicly exposed by the `rustdoc-types`. It is already documented in that crate's README and Cargo.toml, but we might as well add some information to the crate docs themselves c: Follow up to: - #131936 - [rust-lang/rustdoc-types#42][1] [1]: https://github.com/rust-lang/rustdoc-types/pull/42 --- src/rustdoc-json-types/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/rustdoc-json-types') diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index c4e142342a8..33ec59dad5b 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -2,6 +2,18 @@ //! //! These types are the public API exposed through the `--output-format json` flag. The [`Crate`] //! struct is the root of the JSON blob and all other items are contained within. +//! +//! We expose a `rustc-hash` feature that is disabled by default. This feature switches the +//! [`std::collections::HashMap`] for [`rustc_hash::FxHashMap`] to improve the performance of said +//! `HashMap` in specific situations. +//! +//! `cargo-semver-checks` for example, saw a [-3% improvement][1] when benchmarking using the +//! `aws_sdk_ec2` JSON output (~500MB of JSON). As always, we recommend measuring the impact before +//! turning this feature on, as [`FxHashMap`][2] only concerns itself with hash speed, and may +//! increase the number of collisions. +//! +//! [1]: https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/rustc-hash.20and.20performance.20of.20rustdoc-types/near/474855731 +//! [2]: https://crates.io/crates/rustc-hash #[cfg(not(feature = "rustc-hash"))] use std::collections::HashMap; -- cgit 1.4.1-3-g733a5 From f04759165241a7c3445a88cb6a2a2ca575d94302 Mon Sep 17 00:00:00 2001 From: Jalil David Salamé Messina Date: Sun, 20 Oct 2024 18:55:49 +0200 Subject: feat(rustdoc-json-types): mark simple enums as copy Fixes [rust-lang/rustdoc-types#26](https://github.com/rust-lang/rustdoc-types/issues/26) --- src/rustdoc-json-types/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/rustdoc-json-types') diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index c4e142342a8..4d2dd5fe9a5 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -308,7 +308,7 @@ pub struct Id(pub u32); /// The fundamental kind of an item. Unlike [`ItemEnum`], this does not carry any aditional info. /// /// Part of [`ItemSummary`]. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum ItemKind { /// A module declaration, e.g. `mod foo;` or `mod foo {}` @@ -892,7 +892,7 @@ pub enum GenericBound { } /// A set of modifiers applied to a trait. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum TraitBoundModifier { /// Marks the absence of a modifier. @@ -1193,7 +1193,7 @@ pub struct ProcMacro { } /// The way a [`ProcMacro`] is declared to be used. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum MacroKind { /// A bang macro `foo!()`. -- cgit 1.4.1-3-g733a5 From afa75f0aa5c90b9ea7d4887f00aed7041104a853 Mon Sep 17 00:00:00 2001 From: Jalil David Salamé Messina Date: Sun, 20 Oct 2024 18:57:17 +0200 Subject: fix(rustdoc-json-types): typos Typos found some typos in the file, so I fixed them c: --- src/rustdoc-json-types/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/rustdoc-json-types') diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 4d2dd5fe9a5..7b64edfad7d 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -305,7 +305,7 @@ pub enum AssocItemConstraintKind { // FIXME(aDotInTheVoid): Consider making this non-public in rustdoc-types. pub struct Id(pub u32); -/// The fundamental kind of an item. Unlike [`ItemEnum`], this does not carry any aditional info. +/// The fundamental kind of an item. Unlike [`ItemEnum`], this does not carry any additional info. /// /// Part of [`ItemSummary`]. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -698,7 +698,7 @@ pub enum Abi { Aapcs { unwind: bool }, /// Can be specified as `extern "win64"`. Win64 { unwind: bool }, - /// Can be specifed as `extern "sysv64"`. + /// Can be specified as `extern "sysv64"`. SysV64 { unwind: bool }, /// Can be specified as `extern "system"`. System { unwind: bool }, @@ -996,7 +996,7 @@ pub enum Type { QualifiedPath { /// The name of the associated type in the parent type. /// - /// ```ignore (incomplete expresssion) + /// ```ignore (incomplete expression) /// as Iterator>::Item /// // ^^^^ /// ``` @@ -1083,7 +1083,7 @@ pub struct FunctionSignature { #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Trait { /// Whether the trait is marked `auto` and is thus implemented automatically - /// for all aplicable types. + /// for all applicable types. pub is_auto: bool, /// Whether the trait is marked as `unsafe`. pub is_unsafe: bool, -- cgit 1.4.1-3-g733a5