#![feature(generic_const_exprs)]
#![feature(portable_simd)]
use target_features::CURRENT_TARGET;
use std::simd::Simd;
fn main() {}
struct BitVec<const BIT_LEN: usize>
where [(); { inline_unit_len(BIT_LEN) }]:
{
inline: Simd<u8, { inline_unit_len(BIT_LEN) }>,
}
type Lane = usize;
const fn inline_unit_len(bit_len: usize) -> usize {
8
}
I expected to see this happen: No compilation error
Instead, this happened: compilation error
❯ cargo run --
Compiling test44 v0.1.0 (/home/yyy/test44)
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1766:12
|
1766 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: unused import: `target_features::CURRENT_TARGET`
--> src/main.rs:1769:5
|
1769 | use target_features::CURRENT_TARGET;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unnecessary braces around const expression
--> src/main.rs:1775:12
|
1775 | where [(); { inline_unit_len(BIT_LEN) }]:
| ^^ ^^
|
= note: `#[warn(unused_braces)]` on by default
help: remove these braces
|
1775 - where [(); { inline_unit_len(BIT_LEN) }]:
1775 + where [(); inline_unit_len(BIT_LEN)]:
|
error[E0277]: the trait bound `LaneCount<{ inline_unit_len(BIT_LEN) }>: SupportedLaneCount` is not satisfied
--> src/main.rs:1777:13
|
1777 | inline: Simd<u8, { inline_unit_len(BIT_LEN) }>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `SupportedLaneCount` is not implemented for `LaneCount<{ inline_unit_len(BIT_LEN) }>`
|
= help: the following other types implement trait `SupportedLaneCount`:
LaneCount<1>
LaneCount<2>
LaneCount<4>
LaneCount<8>
LaneCount<16>
LaneCount<32>
LaneCount<64>
note: required by a bound in `Simd`
--> /rustc/381d69953bb7c3390cec0fee200f24529cb6320f/library/core/src/../../portable-simd/crates/core_simd/src/vector.rs:103:1
warning: unused variable: `bit_len`
--> src/main.rs:1782:26
|
1782 | const fn inline_unit_len(bit_len: usize) -> usize {
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_bit_len`
|
= note: `#[warn(unused_variables)]` on by default
For more information about this error, try `rustc --explain E0277`.
warning: `test44` (bin "test44") generated 4 warnings
error: could not compile `test44` (bin "test44") due to 1 previous error; 4 warnings emitted
This is mostly a limitation of generic const exprs, but issues like this is one of the reasons I would like to change length validation to a post-mono check (see #364)
I tried this code:
I expected to see this happen: No compilation error
Instead, this happened: compilation error
Meta
rustc --version --verbose
: