Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump MSRV to 1.56 (Edition 2021) #1269

Merged
merged 6 commits into from Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
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
3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -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
7 changes: 4 additions & 3 deletions README.md
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
3 changes: 2 additions & 1 deletion rand_chacha/Cargo.toml
Expand Up @@ -12,7 +12,8 @@ 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" }
Expand Down
2 changes: 1 addition & 1 deletion rand_chacha/README.md
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
3 changes: 2 additions & 1 deletion rand_core/Cargo.toml
Expand Up @@ -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
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
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
3 changes: 2 additions & 1 deletion rand_distr/Cargo.toml
Expand Up @@ -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 Down
2 changes: 1 addition & 1 deletion rand_distr/README.md
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
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
3 changes: 2 additions & 1 deletion rand_pcg/Cargo.toml
Expand Up @@ -12,7 +12,8 @@ Selected PCG random number generators
"""
keywords = ["random", "rng", "pcg"]
categories = ["algorithms", "no-std"]
edition = "2018"
edition = "2021"
rust-version = "1.56"

[features]
serde1 = ["serde"]
Expand Down
2 changes: 1 addition & 1 deletion rand_pcg/README.md
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
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
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
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
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
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