-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
arrays as const parameters result in bad error messages #81698
Comments
The fix is let c = a.shuffle2::<{ [3, 1] }>(b); Due to parsing ambiguities generic arguments currently need to be put into braces, unless they are really simple (like |
Oh, cool! That does compile! I knew about that but wasn't sure if that was the problem because I thought that was just for expressions? I guess that's technically an array expression? That is none of the errors I was presented with, though, which makes this a diagnostics problem I suppose? |
error: unmatched angle bracket
--> src/lib.rs:8:10
|
8 | foo::<(20 * 100 + 20 * 10 + 1)>(); // ok: const expression contains no generic parameters
| ^ help: remove extra angle bracket I believe diagnostic for const generic (example taken from https://blog.rust-lang.org/2021/02/26/const-generics-mvp-beta) needs to be improved too before release, at least I thought that |
Arrays as const parameters still have bad error messages. #![feature(adt_const_params)]
pub struct SimdU32<const LANES: usize>([u32; LANES]);
impl<const LANES: usize> SimdU32<LANES> {
pub fn shuffle2<const M: [u32; 2]>(self) -> SimdU32<2> {
todo!()
}
}
fn main() {
let a = SimdU32([2, 4, 1, 9]);
let c = a.shuffle2::<[3, 1]>();
} same with tuples #![feature(adt_const_params)]
pub struct SimdU32<const LANES: usize>([u32; LANES]);
impl<const LANES: usize> SimdU32<LANES> {
pub fn shuffle2<const M: (u32, u32)>(self) -> SimdU32<2> {
todo!()
}
}
fn main() {
let a = SimdU32([2, 4, 1, 9]);
let c = a.shuffle2::<(3, 1)>();
} |
@rustbot claim |
This is a much abbreviated version of the code from my experiments with adding a shuffle API to the stdsimd repo, it probably needs further reduction but I wanted to file this before I forgot:
I expected to see this happen: it works, provides a useful error, or even just ICEs.
Instead, this happened: I got a request to input a type instead!
And no, that doesn't work either if you put it in, because instead you get:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: