Skip to content

Commit

Permalink
Use explicit features rather than implicit.
Browse files Browse the repository at this point in the history
In Rust 2024 edition, implicit features from optional dependencies
are going away and explicit features are required.

This changes all features using optional dependencies to use the
"dep:" syntax to avoid creating implicit features.

It also adds new explicit features for optional dependencies that
didn't previously have an explicit feature to enable them.

This does mean that some previously publicly visible features are
now gone, like `serde`. These features would not have worked
previously as the code is guarded by, for example, checks for
`feature = "serde1"`, so just enabling the optional dependency
wouldn't have been sufficient to enable the code.
  • Loading branch information
waywardmonkeys committed Jul 24, 2024
1 parent 2d5948d commit b745e18
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
- Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to yield `high` (#1462)
- Fix portability of `rand::distributions::Slice` (#1469)
- Rename `rand::distributions` to `rand::distr` (#1470)
- Add explicit feature `log`, remove implicit features `serde` and `rand_chacha` (#1473)

## [0.9.0-alpha.1] - 2024-03-18
- Add the `Slice::num_choices` method to the Slice distribution (#1402)
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ features = ["small_rng", "serde1"]
# Meta-features:
default = ["std", "std_rng", "getrandom", "small_rng"]
nightly = [] # some additions requiring nightly Rust
serde1 = ["serde", "rand_core/serde1"]
serde1 = ["dep:serde", "rand_core/serde1"]

# Option (enabled by default): without "std" rand uses libcore; this option
# enables functionality expected to be available on a standard platform.
Expand All @@ -46,7 +46,7 @@ getrandom = ["rand_core/getrandom"]
simd_support = ["zerocopy/simd-nightly"]

# Option (enabled by default): enable StdRng
std_rng = ["rand_chacha"]
std_rng = ["dep:rand_chacha"]

# Option: enable SmallRng
small_rng = []
Expand All @@ -56,6 +56,9 @@ small_rng = []
# Note: enabling this option is expected to affect reproducibility of results.
unbiased = []

# Option: enable logging
log = ["dep:log"]

[workspace]
members = [
"rand_core",
Expand Down
3 changes: 3 additions & 0 deletions rand_chacha/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- Remove implicit feature `serde` (#1473)

## [0.9.0-alpha.1] - 2024-03-18

## [0.9.0-alpha.0] - 2024-02-18
Expand Down
2 changes: 1 addition & 1 deletion rand_chacha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ rand_core = { path = "../rand_core", version = "=0.9.0-alpha.1", features = ["ge
default = ["std"]
getrandom = ["rand_core/getrandom"]
std = ["ppv-lite86/std", "rand_core/std"]
serde1 = ["serde"]
serde1 = ["dep:serde"]
1 change: 1 addition & 0 deletions rand_core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
- Bump the MSRV to 1.61.0
- Remove implicit feature `serde` (#1473)

## [0.9.0-alpha.1] - 2024-03-18

Expand Down
3 changes: 2 additions & 1 deletion rand_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ all-features = true
[features]
std = ["alloc", "getrandom?/std"]
alloc = [] # enables Vec and Box support without std
serde1 = ["serde"] # enables serde for BlockRng wrapper
getrandom = ["dep:getrandom"]
serde1 = ["dep:serde"] # enables serde for BlockRng wrapper

[dependencies]
serde = { version = "1", features = ["derive"], optional = true }
Expand Down
3 changes: 3 additions & 0 deletions rand_distr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add plots for `rand_distr` distributions to documentation (#1434)
- Add `PertBuilder`, fix case where mode ≅ mean (#1452)

### Changes
- Add explicit feature for `serde_with`, remove implicit feature `serde` (#1473)

## [0.5.0-alpha.1] - 2024-03-18
- Target `rand` version `0.9.0-alpha.1`

Expand Down
3 changes: 2 additions & 1 deletion rand_distr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ alloc = ["rand/alloc"]
# feature (default-enabled) will have the same effect.
std_math = ["num-traits/std"]

serde1 = ["serde", "rand/serde1"]
serde1 = ["dep:serde", "rand/serde1"]
serde_with = ["dep:serde_with"]

[dependencies]
rand = { path = "..", version = "=0.9.0-alpha.1", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions rand_pcg/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Remove implicit feature `serde` (#1473)

## [0.9.0-alpha.1] - 2024-03-18

## [0.9.0-alpha.0] - 2024-02-18
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all-features = true
rustdoc-args = ["--generate-link-to-definition"]

[features]
serde1 = ["serde"]
serde1 = ["dep:serde"]
getrandom = ["rand_core/getrandom"]

[dependencies]
Expand Down

0 comments on commit b745e18

Please sign in to comment.