Skip to content

Commit

Permalink
Bump MSRV to 1.56 (Edition 2021) (#1269)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dhardy authored Dec 6, 2022
1 parent 7aa25d5 commit 19169cb
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 48 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# Test both windows-gnu and windows-msvc; use beta rust on one
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
toolchain: 1.51.0 # MSRV
toolchain: 1.56.0 # MSRV
- os: ubuntu-latest
deps: sudo apt-get update ; sudo apt install gcc-multilib
target: i686-unknown-linux-gnu
Expand Down Expand Up @@ -161,17 +161,17 @@ jobs:
- name: Build top-level only
run: cargo build --target=thumbv6m-none-eabi --no-default-features

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

test-ios:
runs-on: macos-latest
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand"
version = "0.8.5"
version = "0.9.0"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -13,7 +13,8 @@ Random number generators and other randomness functionality.
keywords = ["random", "rng"]
categories = ["algorithms", "no-std"]
autobenches = true
edition = "2018"
edition = "2021"
rust-version = "1.56"
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]

[package.metadata.docs.rs]
Expand Down Expand Up @@ -59,17 +60,17 @@ members = [
]

[dependencies]
rand_core = { path = "rand_core", version = "0.6.0" }
rand_core = { path = "rand_core", version = "0.7.0" }
log = { version = "0.4.4", optional = true }
serde = { version = "1.0.103", features = ["derive"], optional = true }
rand_chacha = { path = "rand_chacha", version = "0.3.0", default-features = false, optional = true }
rand_chacha = { path = "rand_chacha", version = "0.4.0", default-features = false, optional = true }

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

[dev-dependencies]
rand_pcg = { path = "rand_pcg", version = "0.3.0" }
rand_pcg = { path = "rand_pcg", version = "0.4.0" }
# Only to test serde1
bincode = "1.2.1"
rayon = "1.5.3"
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand)
[![API](https://docs.rs/rand/badge.svg)](https://docs.rs/rand)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)

A Rust library for random number generation, featuring:

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

### Rust version requirements (MSRV)
### Rust version requirements

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

## Crate Features

Expand Down
7 changes: 4 additions & 3 deletions rand_chacha/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand_chacha"
version = "0.3.1"
version = "0.4.0"
authors = ["The Rand Project Developers", "The Rust Project Developers", "The CryptoCorrosion Contributors"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -12,10 +12,11 @@ ChaCha random number generator
"""
keywords = ["random", "rng", "chacha"]
categories = ["algorithms", "no-std"]
edition = "2018"
edition = "2021"
rust-version = "1.56"

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

Expand Down
2 changes: 1 addition & 1 deletion rand_chacha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_chacha)
[![API](https://docs.rs/rand_chacha/badge.svg)](https://docs.rs/rand_chacha)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)

A cryptographically secure random number generator that uses the ChaCha
algorithm.
Expand Down
5 changes: 3 additions & 2 deletions rand_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand_core"
version = "0.6.4"
version = "0.7.0"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -12,7 +12,8 @@ Core random number generator traits and tools for implementation.
"""
keywords = ["random", "rng"]
categories = ["algorithms", "no-std"]
edition = "2018"
edition = "2021"
rust-version = "1.56"

[package.metadata.docs.rs]
# To build locally:
Expand Down
2 changes: 1 addition & 1 deletion rand_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core)
[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)

Core traits and error types of the [rand] library, plus tools for implementing
RNGs.
Expand Down
4 changes: 2 additions & 2 deletions rand_core/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ impl<R: BlockRngCore<Item = u64>> RngCore for BlockRng64<R> {
let mut read_len = 0;
self.half_used = false;
while read_len < dest.len() {
if self.index as usize >= self.results.as_ref().len() {
if self.index >= self.results.as_ref().len() {
self.core.generate(&mut self.results);
self.index = 0;
}

let (consumed_u64, filled_u8) = fill_via_u64_chunks(
&self.results.as_ref()[self.index as usize..],
&self.results.as_ref()[self.index..],
&mut dest[read_len..],
);

Expand Down
11 changes: 6 additions & 5 deletions rand_distr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand_distr"
version = "0.4.3"
version = "0.5.0"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -12,7 +12,8 @@ Sampling from random number distributions
"""
keywords = ["random", "rng", "distribution", "probability"]
categories = ["algorithms", "no-std"]
edition = "2018"
edition = "2021"
rust-version = "1.56"
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]

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

[dependencies]
rand = { path = "..", version = "0.8.0", default-features = false }
rand = { path = "..", version = "0.9.0", default-features = false }
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
serde = { version = "1.0.103", features = ["derive"], optional = true }

[dev-dependencies]
rand_pcg = { version = "0.3.0", path = "../rand_pcg" }
rand_pcg = { version = "0.4.0", path = "../rand_pcg" }
# For inline examples
rand = { path = "..", version = "0.8.0", default-features = false, features = ["std_rng", "std", "small_rng"] }
rand = { path = "..", version = "0.9.0", default-features = false, features = ["std_rng", "std", "small_rng"] }
# Histogram implementation for testing uniformity
average = { version = "0.13", features = [ "std" ] }
# Special functions for testing distributions
Expand Down
2 changes: 1 addition & 1 deletion rand_distr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_distr)
[![API](https://docs.rs/rand_distr/badge.svg)](https://docs.rs/rand_distr)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)

Implements a full suite of random number distribution sampling routines.

Expand Down
5 changes: 3 additions & 2 deletions rand_distr/benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.0.0"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
description = "Criterion benchmarks of the rand_distr crate"
edition = "2018"
edition = "2021"
rust-version = "1.56"
publish = false

[workspace]
Expand All @@ -19,4 +20,4 @@ rand_pcg = { path = "../../rand_pcg/" }
[[bench]]
name = "distributions"
path = "src/distributions.rs"
harness = false
harness = false
7 changes: 4 additions & 3 deletions rand_pcg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand_pcg"
version = "0.3.1"
version = "0.4.0"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -12,13 +12,14 @@ Selected PCG random number generators
"""
keywords = ["random", "rng", "pcg"]
categories = ["algorithms", "no-std"]
edition = "2018"
edition = "2021"
rust-version = "1.56"

[features]
serde1 = ["serde"]

[dependencies]
rand_core = { path = "../rand_core", version = "0.6.0" }
rand_core = { path = "../rand_core", version = "0.7.0" }
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_pcg)
[![API](https://docs.rs/rand_pcg/badge.svg)](https://docs.rs/rand_pcg)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.51+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.56+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements)

Implements a selection of PCG random number generators.

Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ where_single_line = true
# struct_field_align_threshold = 20

# Compatibility:
edition = "2018" # we require compatibility back to 1.32.0
edition = "2021"

# Misc:
inline_attribute_width = 80
Expand Down
2 changes: 1 addition & 1 deletion src/distributions/uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ where Borrowed: SampleUniform
{
#[inline(always)]
fn borrow(&self) -> &Borrowed {
*self
self
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/rngs/adapter/reseeding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ where
ReseedingCore {
inner: rng,
reseeder,
threshold: threshold as i64,
bytes_until_reseed: threshold as i64,
threshold,
bytes_until_reseed: threshold,
fork_counter: 0,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/seq/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ where R: Rng + ?Sized {

if amount < 163 {
const C: [[f32; 2]; 2] = [[1.6, 8.0 / 45.0], [10.0, 70.0 / 9.0]];
let j = if length < 500_000 { 0 } else { 1 };
let j = usize::from(length >= 500_000);
let amount_fp = amount as f32;
let m4 = C[0][j] * amount_fp;
// Short-cut: when amount < 12, floyd's is always faster
Expand All @@ -249,7 +249,7 @@ where R: Rng + ?Sized {
}
} else {
const C: [f32; 2] = [270.0, 330.0 / 9.0];
let j = if length < 500_000 { 0 } else { 1 };
let j = usize::from(length >= 500_000);
if (length as f32) < C[j] * (amount as f32) {
sample_inplace(rng, length, amount)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/seq/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ impl<'a, S: Index<usize, Output = T> + ?Sized + 'a, T: 'a> Iterator for SliceCho

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

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

0 comments on commit 19169cb

Please sign in to comment.