Skip to content

Commit 592137a

Browse files
committed
Auto merge of #125 - 0ndorio:allow_to_disable_ahash_feature, r=Amanieu
Introduce `ahash-compile-time-rng` feature. **Content** 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 depended 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] rust-lang/cargo#5760 --- **Warnings** (1) Compiling `ahash` with disabled `compile-time-rng` feature is currently broken and requires tkaitchuck/aHash#25 to be merged in advance. (2) This introduces a hidden behavior change for all dependent crates, using hashbrown with `default-features = false` and `features = 'ahash'`. This happens as the `ahash` feature no longer implicitly enables the `compile-time-rng` feature of `ahash`. --- Is the naming of the feature okay? Do I need to add any additional changes?
2 parents 861a110 + 92bc9f8 commit 592137a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build = "build.rs"
1414

1515
[dependencies]
1616
# For the default hasher
17-
ahash = { version = "0.2.11", optional = true }
17+
ahash = { version = "0.2.11", optional = true, default-features = false }
1818

1919
# For external trait impls
2020
rayon = { version = "1.0", optional = true }
@@ -37,7 +37,13 @@ serde_test = "1.0"
3737
doc-comment = "0.3.1"
3838

3939
[features]
40-
default = ["ahash", "inline-more"]
40+
default = [
41+
"ahash",
42+
"ahash-compile-time-rng",
43+
"inline-more",
44+
]
45+
46+
ahash-compile-time-rng = [ "ahash/compile-time-rng" ]
4147
nightly = []
4248
rustc-internal-api = []
4349
rustc-dep-of-std = ["nightly", "core", "compiler_builtins", "alloc", "rustc-internal-api"]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ This crate has the following Cargo features:
104104
- `raw`: Enables access to the experimental and unsafe `RawTable` API.
105105
- `inline-more`: Adds inline hints to most functions, improving run-time performance at the cost
106106
of compilation time. (enabled by default)
107+
- `ahash`: Compiles with ahash as default hasher. (enabled by default)
108+
- `ahash-compile-time-rng`: Activates the `compile-time-rng` feature of ahash, to increase the
109+
DOS-resistance, but can result in issues for `no_std` builds. More details in
110+
[issue#124](https://github.com/rust-lang/hashbrown/issues/124). (enabled by default)
107111

108112
## License
109113

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
cfg_doctest,
2323
)
2424
)]
25+
#![allow(
26+
clippy::doc_markdown,
27+
clippy::module_name_repetitions,
28+
clippy::must_use_candidate
29+
)]
2530
#![warn(missing_docs)]
26-
#![allow(clippy::module_name_repetitions, clippy::doc_markdown)]
2731
#![warn(rust_2018_idioms)]
2832

2933
#[cfg(test)]

0 commit comments

Comments
 (0)