Skip to content

Commit

Permalink
Auto merge of #125 - 0ndorio:allow_to_disable_ahash_feature, r=Amanieu
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
bors committed Oct 31, 2019
2 parents 861a110 + 92bc9f8 commit 592137a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 592137a

Please sign in to comment.