Open
Description
Code
https://github.com/BLAKE3-team/BLAKE3 @ 60ed9295f58ba975df58a67b2bfe435f478d05ea +
diff --git a/benches/bench.rs b/benches/bench.rs
index e89f04c..ea21f3c 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -85,24 +85,24 @@ fn bench_single_compression_avx512(b: &mut Bencher) {
}
}
-fn bench_many_chunks_fn(b: &mut Bencher, platform: Platform) {
+fn bench_many_fn<const LEN: usize>(increment: blake3::IncrementCounter, b: &mut Bencher, platform: Platform) {
let degree = platform.simd_degree();
let mut inputs = Vec::new();
for _ in 0..degree {
- inputs.push(RandomInput::new(b, CHUNK_LEN));
+ inputs.push(RandomInput::new(b, LEN));
}
b.iter(|| {
- let input_arrays: ArrayVec<&[u8; CHUNK_LEN], MAX_SIMD_DEGREE> = inputs
+ let input_arrays: ArrayVec<&[u8; LEN], MAX_SIMD_DEGREE> = inputs
.iter_mut()
.take(degree)
- .map(|i| array_ref!(i.get(), 0, CHUNK_LEN))
+ .map(|i| array_ref!(i.get(), 0, LEN))
.collect();
let mut out = [0; MAX_SIMD_DEGREE * OUT_LEN];
platform.hash_many(
&input_arrays[..],
&[0; 8],
0,
- blake3::IncrementCounter::Yes,
+ increment,
0,
0,
0,
@@ -111,6 +111,10 @@ fn bench_many_chunks_fn(b: &mut Bencher, platform: Platform) {
});
}
+fn bench_many_chunks_fn(b: &mut Bencher, platform: Platform) {
+ bench_many_fn::<CHUNK_LEN>(blake3::IncrementCounter::Yes, b, platform)
+}
+
#[bench]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn bench_many_chunks_sse2(b: &mut Bencher) {
@@ -155,31 +159,8 @@ fn bench_many_chunks_wasm(b: &mut Bencher) {
bench_many_chunks_fn(b, Platform::wasm32_simd().unwrap());
}
-// TODO: When we get const generics we can unify this with the chunks code.
fn bench_many_parents_fn(b: &mut Bencher, platform: Platform) {
- let degree = platform.simd_degree();
- let mut inputs = Vec::new();
- for _ in 0..degree {
- inputs.push(RandomInput::new(b, BLOCK_LEN));
- }
- b.iter(|| {
- let input_arrays: ArrayVec<&[u8; BLOCK_LEN], MAX_SIMD_DEGREE> = inputs
- .iter_mut()
- .take(degree)
- .map(|i| array_ref!(i.get(), 0, BLOCK_LEN))
- .collect();
- let mut out = [0; MAX_SIMD_DEGREE * OUT_LEN];
- platform.hash_many(
- &input_arrays[..],
- &[0; 8],
- 0,
- blake3::IncrementCounter::No,
- 0,
- 0,
- 0,
- &mut out,
- );
- });
+ bench_many_fn::<BLOCK_LEN>(blake3::IncrementCounter::No, b, platform)
}
#[bench]
+ `cargo bench`
Current output
error[E0401]: can't use generic parameters from outer item
--> benches/bench.rs:98:45
|
88 | fn bench_many_fn<const LEN: usize>(increment: blake3::IncrementCounter, b: &mut Bencher, platform: Platform) {
| --- const parameter from outer item
...
98 | .map(|i| array_ref!(i.get(), 0, LEN))
| -----------------------^^^-
| | |
| | use of generic parameter from outer item
| help: try introducing a local generic parameter here: `LEN,`
Desired output
idk
Rationale and extra context
This is baffling. Where does it want me to do this. What is this about.
Other cases
Rust Version
rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Diagnostics: Confusing error or lint that should be reworked.Diagnostics: A structured suggestion resulting in incorrect code.Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleRelevant to the compiler team, which will review and decide on the PR/issue.