Skip to content

Commit 8112daa

Browse files
authored
Merge pull request #703 from dhardy/master
Disable std feature by default in rand_core and rand_jitter
2 parents c864540 + 77e952f commit 8112daa

File tree

16 files changed

+31
-29
lines changed

16 files changed

+31
-29
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ members = [
4646
]
4747

4848
[dependencies]
49-
rand_core = { path = "rand_core", version = "0.3", default-features = false }
49+
rand_core = { path = "rand_core", version = "0.4" }
5050
rand_pcg = { path = "rand_pcg", version = "0.1" }
51-
rand_jitter = { path = "rand_jitter", version = "0.1", default-features = false }
51+
rand_jitter = { path = "rand_jitter", version = "0.1" }
5252
rand_os = { path = "rand_os", version = "0.1", optional = true }
5353
# only for deprecations and benches:
5454
rand_isaac = { path = "rand_isaac", version = "0.1" }
@@ -84,4 +84,4 @@ autocfg = "0.1"
8484
all-features = true
8585

8686
[patch.crates-io]
87-
rand_core = { path = "rand_core", version = "0.3", default-features = false }
87+
rand_core = { path = "rand_core", version = "0.4" }

appveyor.yml

-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ test_script:
3737
- cargo test --features=serde1,log
3838
- cargo test --benches --features=nightly
3939
- cargo test --examples
40-
- cargo test --package rand_core
41-
- cargo test --package rand_core --no-default-features --features=alloc
42-
- cargo test --package rand_isaac --features=serde1
43-
- cargo test --package rand_xorshift --features=serde1
44-
- cargo test --package rand_xoshiro
45-
- cargo test --package rand_chacha
46-
- cargo test --package rand_hc
4740
- cargo test --manifest-path rand_core/Cargo.toml
4841
- cargo test --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc
4942
- cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1

rand_chacha/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ travis-ci = { repository = "rust-random/rand" }
1919
appveyor = { repository = "rust-random/rand" }
2020

2121
[dependencies]
22-
rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
22+
rand_core = { path = "../rand_core", version = "0.4" }
2323

2424
[build-dependencies]
2525
autocfg = "0.1"

rand_core/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.4.0] - 2019-01-24
8+
- Disable the `std` feature by default (#702)
9+
710
## [0.3.0] - 2018-09-24
811
- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537)
912

rand_core/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_core"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT/Apache-2.0"
66
readme = "README.md"
@@ -18,7 +18,6 @@ travis-ci = { repository = "rust-random/rand" }
1818
appveyor = { repository = "rust-random/rand" }
1919

2020
[features]
21-
default = ["std"]
2221
std = ["alloc"] # use std library; should be default but for above bug
2322
alloc = [] # enables Vec and Box support without std
2423
serde1 = ["serde", "serde_derive"] # enables serde for BlockRng wrapper

rand_core/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ The traits and error types are also available via `rand`.
4444

4545
`rand_core` supports `no_std` and `alloc`-only configurations, as well as full
4646
`std` functionality. The differences between `no_std` and full `std` are small,
47-
comprising `RngCore` support for `Box<R>` types where `R: RngCore`, as well as
47+
comprising `RngCore` support for `Box<R>` types where `R: RngCore`,
48+
`std::io::Read` support for types supporting `RngCore`, and
4849
extensions to the `Error` type's functionality.
4950

50-
Due to [rust-lang/cargo#1596](https://github.com/rust-lang/cargo/issues/1596),
51-
`rand_core` is built without `std` support by default. Since features are
52-
unioned across the whole dependency tree, any crate using `rand` with its
53-
default features will also enable `std` support in `rand_core`.
51+
The `std` feature is *not enabled by default*. This is primarily to avoid build
52+
problems where one crate implicitly requires `rand_core` with `std` support and
53+
another crate requires `rand` *without* `std` support. However, the `rand` crate
54+
continues to enable `std` support by default, both for itself and `rand_core`.
5455

5556
The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG
5657
implementations that use the `BlockRng` or `BlockRng64` wrappers.

rand_hc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ travis-ci = { repository = "rust-random/rand" }
1818
appveyor = { repository = "rust-random/rand" }
1919

2020
[dependencies]
21-
rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
21+
rand_core = { path = "../rand_core", version = "0.4" }

rand_isaac/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ appveyor = { repository = "rust-random/rand" }
2121
serde1 = ["serde", "serde_derive", "rand_core/serde1"]
2222

2323
[dependencies]
24-
rand_core = { path = "../rand_core", version = "0.3", default-features=false }
24+
rand_core = { path = "../rand_core", version = "0.4" }
2525
serde = { version = "1", optional = true }
2626
serde_derive = { version = "^1.0.38", optional = true }
2727

rand_jitter/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.1.0] - 2019-01-04
7+
## [0.1.0] - 2019-01-24
88
Initial release.

rand_jitter/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ travis-ci = { repository = "rust-random/rand" }
1414
appveyor = { repository = "rust-random/rand" }
1515

1616
[dependencies]
17-
rand_core = { path = "../rand_core", version = "0.3", default-features = false }
17+
rand_core = { path = "../rand_core", version = "0.4" }
1818
log = { version = "0.4", optional = true }
1919

2020
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
@@ -24,6 +24,4 @@ libc = "0.2"
2424
winapi = { version = "0.3", features = ["profileapi"] }
2525

2626
[features]
27-
default = ["std"]
28-
std = []
29-
27+
std = ["rand_core/std"]

rand_jitter/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ Links:
2222
- [API documentation (docs.rs)](https://docs.rs/rand_jitter)
2323
- [Changelog](CHANGELOG.md)
2424

25+
## Features
26+
27+
This crate has optional `std` support which is *disabled by default*;
28+
this feature is required to provide the `JitterRng::new` function;
29+
without `std` support a timer must be supplied via `JitterRng::new_with_timer`.
30+
2531
## Quality testing
2632

2733
`JitterRng::new()` has build-in, but limited, quality testing, however

rand_jitter/tests/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ extern crate rand_jitter;
22
extern crate rand_core;
33

44
use rand_jitter::JitterRng;
5+
#[cfg(feature = "std")]
56
use rand_core::RngCore;
67

8+
#[cfg(feature = "std")]
79
#[test]
810
fn test_jitter_init() {
911
// Because this is a debug build, measurements here are not representive

rand_os/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ travis-ci = { repository = "rust-random/rand" }
1515
appveyor = { repository = "rust-random/rand" }
1616

1717
[dependencies]
18-
rand_core = { path = "../rand_core", version = "0.3", default-features = false }
18+
rand_core = { path = "../rand_core", version = "0.4", features = ["std"] }
1919
log = { version = "0.4", optional = true }
2020

2121
[target.'cfg(unix)'.dependencies]

rand_pcg/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ appveyor = { repository = "rust-random/rand" }
2222
serde1 = ["serde", "serde_derive"]
2323

2424
[dependencies]
25-
rand_core = { path = "../rand_core", version = "0.3", default-features=false }
25+
rand_core = { path = "../rand_core", version = "0.4" }
2626
serde = { version = "1", optional = true }
2727
serde_derive = { version = "^1.0.38", optional = true }
2828

rand_xorshift/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ appveyor = { repository = "rust-random/rand" }
2121
serde1 = ["serde", "serde_derive"]
2222

2323
[dependencies]
24-
rand_core = { path = "../rand_core", version = ">=0.2, <0.4", default-features=false }
24+
rand_core = { path = "../rand_core", version = "0.4" }
2525
serde = { version = "1", optional = true }
2626
serde_derive = { version = "^1.0.38", optional = true }
2727

rand_xoshiro/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ categories = ["algorithms"]
1313

1414
[dependencies]
1515
byteorder = { version = "1", default-features=false }
16-
rand_core = { path = "../rand_core", version = "0.3", default-features=false }
16+
rand_core = { path = "../rand_core", version = "0.4" }
1717

1818
[dev-dependencies]
1919
rand = { path = "..", version = "0.6", default-features=false } # needed for doctests

0 commit comments

Comments
 (0)