Skip to content

Commit da3b367

Browse files
committed
Merge branch 'fix-clippy' into fix-unsafe-block
2 parents 4e99eee + b7380fd commit da3b367

31 files changed

+788
-159
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
env:
2424
RUSTDOCFLAGS: --cfg doc_cfg
2525
# --all builds all crates, but with default features for other crates (okay in this case)
26-
run: cargo deadlinks --ignore-fragments -- --all --features nightly,serde1,getrandom,small_rng
26+
run: cargo deadlinks --ignore-fragments -- --all --features nightly,serde1,getrandom,small_rng,min_const_gen
2727

2828
test:
2929
runs-on: ${{ matrix.os }}
@@ -77,14 +77,22 @@ jobs:
7777
cargo test --target ${{ matrix.target }} --all-features
7878
cargo test --target ${{ matrix.target }} --benches --features=nightly
7979
cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --benches
80+
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features min_const_gen
8081
- name: Test rand
8182
run: |
8283
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features
8384
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,getrandom,small_rng
8485
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,getrandom,small_rng
85-
# all stable features:
86-
cargo test --target ${{ matrix.target }} --features=serde1,log,small_rng
8786
cargo test --target ${{ matrix.target }} --examples
87+
- name: Test rand (all stable features, non-MSRV)
88+
if: ${{ matrix.toolchain != '1.36.0' }}
89+
run: |
90+
cargo test --target ${{ matrix.target }} --features=serde1,log,small_rng,min_const_gen
91+
- name: Test rand (all stable features, MSRV)
92+
if: ${{ matrix.toolchain == '1.36.0' }}
93+
run: |
94+
# const generics are not stable on 1.36.0
95+
cargo test --target ${{ matrix.target }} --features=serde1,log,small_rng
8896
- name: Test rand_core
8997
run: |
9098
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
1111
## [0.8.5] - 2021-08-20
1212
### Fixes
1313
- Fix build on non-32/64-bit architectures (#1144)
14+
- Fix "min_const_gen" feature for `no_std` (#1173)
1415

15-
### Platform support
16-
- Remove special cases for emscripten (#1142)
16+
### Rngs
17+
- `StdRng`: Switch from HC128 to ChaCha12 on emscripten (#1142).
18+
We now use ChaCha12 on all platforms.
1719

1820
### Documentation
1921
- Added docs about rand's use of const generics (#1150)
2022
- Better random chars example (#1157)
2123

24+
2225
## [0.8.4] - 2021-06-15
2326
### Additions
2427
- Use const-generics to support arrays of all sizes (#1104)

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ rand_chacha = { path = "rand_chacha", version = "0.3.0", default-features = fals
7171
[dependencies.packed_simd]
7272
# NOTE: so far no version works reliably due to dependence on unstable features
7373
package = "packed_simd_2"
74-
version = "0.3.5"
74+
version = "0.3.6"
7575
optional = true
7676
features = ["into_bits"]
7777

LICENSE-APACHE

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
174174
of your accepting any such warranty or additional liability.
175175

176176
END OF TERMS AND CONDITIONS
177-
178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright [yyyy] [name of copyright owner]
190-
191-
Licensed under the Apache License, Version 2.0 (the "License");
192-
you may not use this file except in compliance with the License.
193-
You may obtain a copy of the License at
194-
195-
https://www.apache.org/licenses/LICENSE-2.0
196-
197-
Unless required by applicable law or agreed to in writing, software
198-
distributed under the License is distributed on an "AS IS" BASIS,
199-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200-
See the License for the specific language governing permissions and
201-
limitations under the License.

benches/distributions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const RAND_BENCH_N: u64 = 1000;
1818

1919
use rand::distributions::{Alphanumeric, Open01, OpenClosed01, Standard, Uniform};
2020
use rand::distributions::uniform::{UniformInt, UniformSampler};
21-
use std::mem::size_of;
22-
use std::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8};
23-
use std::time::Duration;
21+
use core::mem::size_of;
22+
use core::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8};
23+
use core::time::Duration;
2424
use test::{Bencher, black_box};
2525

2626
use rand::prelude::*;
@@ -199,7 +199,7 @@ macro_rules! gen_range_int {
199199
for _ in 0..RAND_BENCH_N {
200200
accum = accum.wrapping_add(rng.gen_range($low..high));
201201
// force recalculation of range each time
202-
high = high.wrapping_add(1) & std::$ty::MAX;
202+
high = high.wrapping_add(1) & core::$ty::MAX;
203203
}
204204
accum
205205
});

benches/generators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern crate test;
1414
const RAND_BENCH_N: u64 = 1000;
1515
const BYTES_LEN: usize = 1024;
1616

17-
use std::mem::size_of;
17+
use core::mem::size_of;
1818
use test::{black_box, Bencher};
1919

2020
use rand::prelude::*;

benches/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn misc_bernoulli_var(b: &mut Bencher) {
9898

9999
#[bench]
100100
fn gen_1kb_u16_iter_repeat(b: &mut Bencher) {
101-
use std::iter;
101+
use core::iter;
102102
let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
103103
b.iter(|| {
104104
let v: Vec<u16> = iter::repeat(()).map(|()| rng.gen()).take(512).collect();
@@ -141,7 +141,7 @@ fn gen_1kb_u16_fill(b: &mut Bencher) {
141141

142142
#[bench]
143143
fn gen_1kb_u64_iter_repeat(b: &mut Bencher) {
144-
use std::iter;
144+
use core::iter;
145145
let mut rng = Pcg64Mcg::from_rng(&mut thread_rng()).unwrap();
146146
b.iter(|| {
147147
let v: Vec<u64> = iter::repeat(()).map(|()| rng.gen()).take(128).collect();

benches/seq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use test::Bencher;
1515

1616
use rand::prelude::*;
1717
use rand::seq::*;
18-
use std::mem::size_of;
18+
use core::mem::size_of;
1919

2020
// We force use of 32-bit RNG since seq code is optimised for use with 32-bit
2121
// generators on all platforms.
@@ -116,7 +116,7 @@ impl<I: ExactSizeIterator + Iterator + Clone> Iterator for WindowHintedIterator<
116116
}
117117

118118
fn size_hint(&self) -> (usize, Option<usize>) {
119-
(std::cmp::min(self.iter.len(), self.window_size), None)
119+
(core::cmp::min(self.iter.len(), self.window_size), None)
120120
}
121121
}
122122

rand_chacha/LICENSE-APACHE

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
174174
of your accepting any such warranty or additional liability.
175175

176176
END OF TERMS AND CONDITIONS
177-
178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright [yyyy] [name of copyright owner]
190-
191-
Licensed under the Apache License, Version 2.0 (the "License");
192-
you may not use this file except in compliance with the License.
193-
You may obtain a copy of the License at
194-
195-
https://www.apache.org/licenses/LICENSE-2.0
196-
197-
Unless required by applicable law or agreed to in writing, software
198-
distributed under the License is distributed on an "AS IS" BASIS,
199-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200-
See the License for the specific language governing permissions and
201-
limitations under the License.

rand_chacha/src/chacha.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ macro_rules! chacha_impl {
182182

183183
impl $ChaChaXRng {
184184
// The buffer is a 4-block window, i.e. it is always at a block-aligned position in the
185-
// stream but if the stream has been seeked it may not be self-aligned.
185+
// stream but if the stream has been sought it may not be self-aligned.
186186

187187
/// Get the offset from the start of the stream, in 32-bit words.
188188
///

0 commit comments

Comments
 (0)