From 2bed868fbcad5be0d8adcd4468ec917d91992343 Mon Sep 17 00:00:00 2001 From: Bruno Kirschner Date: Wed, 30 Oct 2019 10:54:33 +0100 Subject: [PATCH 1/2] Introduce `ahash-compile-time-rng` feature. Disables the default features of `ahash` and reintroduces them through a new feature called `ahash-compile-time-rng`, which is enabled by default. The new feature makes it possible for depended crates to rely on `hashbrown` with `ahash` as default hasher and to disable the `compile-time-rng` at the same time. This might be useful for any dependent crate targeting `no_std`, which contains `rand` or `rand_core` somewhere inside the dependency tree as a bug in cargo accidentally enables the underlying `getrandom` feature if `compile-time-rng` is enabled [1]. ... fixes #124 [1] https://github.com/rust-lang/cargo/issues/5760 --- Cargo.toml | 10 ++++++++-- README.md | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e6fc93d5d..995d84ab94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ build = "build.rs" [dependencies] # For the default hasher -ahash = { version = "0.2.11", optional = true } +ahash = { version = "0.2.11", optional = true, default-features = false } # For external trait impls rayon = { version = "1.0", optional = true } @@ -37,7 +37,13 @@ serde_test = "1.0" doc-comment = "0.3.1" [features] -default = ["ahash", "inline-more"] +default = [ + "ahash", + "ahash-compile-time-rng", + "inline-more", +] + +ahash-compile-time-rng = [ "ahash/compile-time-rng" ] nightly = [] rustc-internal-api = [] rustc-dep-of-std = ["nightly", "core", "compiler_builtins", "alloc", "rustc-internal-api"] diff --git a/README.md b/README.md index d33561e63a..5c9c063784 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,10 @@ This crate has the following Cargo features: - `raw`: Enables access to the experimental and unsafe `RawTable` API. - `inline-more`: Adds inline hints to most functions, improving run-time performance at the cost of compilation time. (enabled by default) +- `ahash`: Compiles with ahash as default hasher. (enabled by default) +- `ahash-compile-time-rng`: Activates the `compile-time-rng` feature of ahash, to increase the + DOS-resistance, but can result in issues for `no_std` builds. More details in + [issue#124](https://github.com/rust-lang/hashbrown/issues/124). (enabled by default) ## License From 92bc9f8133495d2c5c75d1751433d0238aab490f Mon Sep 17 00:00:00 2001 From: Bruno Kirschner Date: Wed, 30 Oct 2019 16:15:45 +0100 Subject: [PATCH 2/2] Allow clippy::must_use_candidate. --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index acf1a709f4..fc33c32b69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,8 +22,12 @@ cfg_doctest, ) )] +#![allow( + clippy::doc_markdown, + clippy::module_name_repetitions, + clippy::must_use_candidate +)] #![warn(missing_docs)] -#![allow(clippy::module_name_repetitions, clippy::doc_markdown)] #![warn(rust_2018_idioms)] #[cfg(test)]