Skip to content

Commit 19169cb

Browse files
authored
Bump MSRV to 1.56 (Edition 2021) (#1269)
* Bump MSRV to 1.56 (Edition 2021) * Apply Clippy suggestions * Bump edition and add rust-version field to Cargo.toml * CI AVR test: unpin nightly rust version * Disable AVR test * Bump crate version numbers for a breaking release
1 parent 7aa25d5 commit 19169cb

File tree

18 files changed

+55
-48
lines changed

18 files changed

+55
-48
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
# Test both windows-gnu and windows-msvc; use beta rust on one
4444
- os: ubuntu-latest
4545
target: x86_64-unknown-linux-gnu
46-
toolchain: 1.51.0 # MSRV
46+
toolchain: 1.56.0 # MSRV
4747
- os: ubuntu-latest
4848
deps: sudo apt-get update ; sudo apt install gcc-multilib
4949
target: i686-unknown-linux-gnu
@@ -161,17 +161,17 @@ jobs:
161161
- name: Build top-level only
162162
run: cargo build --target=thumbv6m-none-eabi --no-default-features
163163

164-
test-avr:
165-
runs-on: ubuntu-latest
166-
steps:
167-
- uses: actions/checkout@v3
168-
- name: Install toolchain
169-
uses: dtolnay/rust-toolchain@master
170-
with:
171-
toolchain: nightly-2021-01-07 # Pinned compiler version due to https://github.com/rust-lang/compiler-builtins/issues/400
172-
components: rust-src
173-
- name: Build top-level only
174-
run: cargo build -Z build-std=core --target=avr-unknown-gnu-atmega328 --no-default-features
164+
# Disabled due to lack of known working compiler versions (not older than our MSRV)
165+
# test-avr:
166+
# runs-on: ubuntu-latest
167+
# steps:
168+
# - uses: actions/checkout@v3
169+
# - name: Install toolchain
170+
# uses: dtolnay/rust-toolchain@nightly
171+
# with:
172+
# components: rust-src
173+
# - name: Build top-level only
174+
# run: cargo build -Z build-std=core --target=avr-unknown-gnu-atmega328 --no-default-features
175175

176176
test-ios:
177177
runs-on: macos-latest

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand"
3-
version = "0.8.5"
3+
version = "0.9.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -13,7 +13,8 @@ Random number generators and other randomness functionality.
1313
keywords = ["random", "rng"]
1414
categories = ["algorithms", "no-std"]
1515
autobenches = true
16-
edition = "2018"
16+
edition = "2021"
17+
rust-version = "1.56"
1718
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
1819

1920
[package.metadata.docs.rs]
@@ -59,17 +60,17 @@ members = [
5960
]
6061

6162
[dependencies]
62-
rand_core = { path = "rand_core", version = "0.6.0" }
63+
rand_core = { path = "rand_core", version = "0.7.0" }
6364
log = { version = "0.4.4", optional = true }
6465
serde = { version = "1.0.103", features = ["derive"], optional = true }
65-
rand_chacha = { path = "rand_chacha", version = "0.3.0", default-features = false, optional = true }
66+
rand_chacha = { path = "rand_chacha", version = "0.4.0", default-features = false, optional = true }
6667

6768
[target.'cfg(unix)'.dependencies]
6869
# Used for fork protection (reseeding.rs)
6970
libc = { version = "0.2.22", optional = true, default-features = false }
7071

7172
[dev-dependencies]
72-
rand_pcg = { path = "rand_pcg", version = "0.3.0" }
73+
rand_pcg = { path = "rand_pcg", version = "0.4.0" }
7374
# Only to test serde1
7475
bincode = "1.2.1"
7576
rayon = "1.5.3"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
66
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand)
77
[![API](https://docs.rs/rand/badge.svg)](https://docs.rs/rand)
8-
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
8+
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
99

1010
A Rust library for random number generation, featuring:
1111

@@ -95,9 +95,10 @@ Some versions of Rand crates have been yanked ("unreleased"). Where this occurs,
9595
the crate's CHANGELOG *should* be updated with a rationale, and a search on the
9696
issue tracker with the keyword `yank` *should* uncover the motivation.
9797

98-
### Rust version requirements (MSRV)
98+
### Rust version requirements
9999

100-
This version of Rand requires Rustc >= 1.51.0.
100+
The Minimum Supported Rust Version (MSRV) is `rustc >= 1.56.0`.
101+
Older releases may work (depending on feature configuration) but are untested.
101102

102103
## Crate Features
103104

rand_chacha/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_chacha"
3-
version = "0.3.1"
3+
version = "0.4.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers", "The CryptoCorrosion Contributors"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -12,10 +12,11 @@ ChaCha random number generator
1212
"""
1313
keywords = ["random", "rng", "chacha"]
1414
categories = ["algorithms", "no-std"]
15-
edition = "2018"
15+
edition = "2021"
16+
rust-version = "1.56"
1617

1718
[dependencies]
18-
rand_core = { path = "../rand_core", version = "0.6.0" }
19+
rand_core = { path = "../rand_core", version = "0.7.0" }
1920
ppv-lite86 = { version = "0.2.14", default-features = false, features = ["simd"] }
2021
serde = { version = "1.0", features = ["derive"], optional = true }
2122

rand_chacha/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
66
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_chacha)
77
[![API](https://docs.rs/rand_chacha/badge.svg)](https://docs.rs/rand_chacha)
8-
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
8+
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
99

1010
A cryptographically secure random number generator that uses the ChaCha
1111
algorithm.

rand_core/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_core"
3-
version = "0.6.4"
3+
version = "0.7.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -12,7 +12,8 @@ Core random number generator traits and tools for implementation.
1212
"""
1313
keywords = ["random", "rng"]
1414
categories = ["algorithms", "no-std"]
15-
edition = "2018"
15+
edition = "2021"
16+
rust-version = "1.56"
1617

1718
[package.metadata.docs.rs]
1819
# To build locally:

rand_core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
66
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core)
77
[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core)
8-
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
8+
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
99

1010
Core traits and error types of the [rand] library, plus tools for implementing
1111
RNGs.

rand_core/src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ impl<R: BlockRngCore<Item = u64>> RngCore for BlockRng64<R> {
381381
let mut read_len = 0;
382382
self.half_used = false;
383383
while read_len < dest.len() {
384-
if self.index as usize >= self.results.as_ref().len() {
384+
if self.index >= self.results.as_ref().len() {
385385
self.core.generate(&mut self.results);
386386
self.index = 0;
387387
}
388388

389389
let (consumed_u64, filled_u8) = fill_via_u64_chunks(
390-
&self.results.as_ref()[self.index as usize..],
390+
&self.results.as_ref()[self.index..],
391391
&mut dest[read_len..],
392392
);
393393

rand_distr/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_distr"
3-
version = "0.4.3"
3+
version = "0.5.0"
44
authors = ["The Rand Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -12,7 +12,8 @@ Sampling from random number distributions
1212
"""
1313
keywords = ["random", "rng", "distribution", "probability"]
1414
categories = ["algorithms", "no-std"]
15-
edition = "2018"
15+
edition = "2021"
16+
rust-version = "1.56"
1617
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
1718

1819
[features]
@@ -23,14 +24,14 @@ std_math = ["num-traits/std"]
2324
serde1 = ["serde", "rand/serde1"]
2425

2526
[dependencies]
26-
rand = { path = "..", version = "0.8.0", default-features = false }
27+
rand = { path = "..", version = "0.9.0", default-features = false }
2728
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
2829
serde = { version = "1.0.103", features = ["derive"], optional = true }
2930

3031
[dev-dependencies]
31-
rand_pcg = { version = "0.3.0", path = "../rand_pcg" }
32+
rand_pcg = { version = "0.4.0", path = "../rand_pcg" }
3233
# For inline examples
33-
rand = { path = "..", version = "0.8.0", default-features = false, features = ["std_rng", "std", "small_rng"] }
34+
rand = { path = "..", version = "0.9.0", default-features = false, features = ["std_rng", "std", "small_rng"] }
3435
# Histogram implementation for testing uniformity
3536
average = { version = "0.13", features = [ "std" ] }
3637
# Special functions for testing distributions

rand_distr/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
66
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_distr)
77
[![API](https://docs.rs/rand_distr/badge.svg)](https://docs.rs/rand_distr)
8-
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
8+
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
99

1010
Implements a full suite of random number distribution sampling routines.
1111

rand_distr/benches/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version = "0.0.0"
44
authors = ["The Rand Project Developers"]
55
license = "MIT OR Apache-2.0"
66
description = "Criterion benchmarks of the rand_distr crate"
7-
edition = "2018"
7+
edition = "2021"
8+
rust-version = "1.56"
89
publish = false
910

1011
[workspace]
@@ -19,4 +20,4 @@ rand_pcg = { path = "../../rand_pcg/" }
1920
[[bench]]
2021
name = "distributions"
2122
path = "src/distributions.rs"
22-
harness = false
23+
harness = false

rand_pcg/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_pcg"
3-
version = "0.3.1"
3+
version = "0.4.0"
44
authors = ["The Rand Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -12,13 +12,14 @@ Selected PCG random number generators
1212
"""
1313
keywords = ["random", "rng", "pcg"]
1414
categories = ["algorithms", "no-std"]
15-
edition = "2018"
15+
edition = "2021"
16+
rust-version = "1.56"
1617

1718
[features]
1819
serde1 = ["serde"]
1920

2021
[dependencies]
21-
rand_core = { path = "../rand_core", version = "0.6.0" }
22+
rand_core = { path = "../rand_core", version = "0.7.0" }
2223
serde = { version = "1", features = ["derive"], optional = true }
2324

2425
[dev-dependencies]

rand_pcg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
66
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_pcg)
77
[![API](https://docs.rs/rand_pcg/badge.svg)](https://docs.rs/rand_pcg)
8-
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
8+
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
99

1010
Implements a selection of PCG random number generators.
1111

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ where_single_line = true
1919
# struct_field_align_threshold = 20
2020

2121
# Compatibility:
22-
edition = "2018" # we require compatibility back to 1.32.0
22+
edition = "2021"
2323

2424
# Misc:
2525
inline_attribute_width = 80

src/distributions/uniform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ where Borrowed: SampleUniform
340340
{
341341
#[inline(always)]
342342
fn borrow(&self) -> &Borrowed {
343-
*self
343+
self
344344
}
345345
}
346346

src/rngs/adapter/reseeding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ where
208208
ReseedingCore {
209209
inner: rng,
210210
reseeder,
211-
threshold: threshold as i64,
212-
bytes_until_reseed: threshold as i64,
211+
threshold,
212+
bytes_until_reseed: threshold,
213213
fork_counter: 0,
214214
}
215215
}

src/seq/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ where R: Rng + ?Sized {
238238

239239
if amount < 163 {
240240
const C: [[f32; 2]; 2] = [[1.6, 8.0 / 45.0], [10.0, 70.0 / 9.0]];
241-
let j = if length < 500_000 { 0 } else { 1 };
241+
let j = usize::from(length >= 500_000);
242242
let amount_fp = amount as f32;
243243
let m4 = C[0][j] * amount_fp;
244244
// Short-cut: when amount < 12, floyd's is always faster
@@ -249,7 +249,7 @@ where R: Rng + ?Sized {
249249
}
250250
} else {
251251
const C: [f32; 2] = [270.0, 330.0 / 9.0];
252-
let j = if length < 500_000 { 0 } else { 1 };
252+
let j = usize::from(length >= 500_000);
253253
if (length as f32) < C[j] * (amount as f32) {
254254
sample_inplace(rng, length, amount)
255255
} else {

src/seq/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ impl<'a, S: Index<usize, Output = T> + ?Sized + 'a, T: 'a> Iterator for SliceCho
641641

642642
fn next(&mut self) -> Option<Self::Item> {
643643
// TODO: investigate using SliceIndex::get_unchecked when stable
644-
self.indices.next().map(|i| &self.slice[i as usize])
644+
self.indices.next().map(|i| &self.slice[i])
645645
}
646646

647647
fn size_hint(&self) -> (usize, Option<usize>) {

0 commit comments

Comments
 (0)