Closed
Description
Code
struct WeirdArray<const N: usize, T>([T; N]);
fn main() {
let a1 = WeirdArray::<1, u8>([1]);
let a2: WeirdArray<2, u8>;
a2 = a1;
}
Current output
error[E0308]: mismatched types
--> src/main.rs:6:10
|
6 | a2 = a1;
| ^^ expected `2`, found `1`
|
= note: expected struct `WeirdArray<_, 2>`
found struct `WeirdArray<_, 1>`
For more information about this error, try `rustc --explain E0308`.
Desired output
error[E0308]: mismatched types
--> src/main.rs:6:10
|
6 | a2 = a1;
| ^^ expected `2`, found `1`
|
= note: expected struct `WeirdArray<2, _>`
found struct `WeirdArray<1, _>`
For more information about this error, try `rustc --explain E0308`.
Rationale and extra context
I believe that putting const generics before type generics used to be a compile error, but it certainly isn't anymore.
Other cases
Rust Version
1.84.0
Anything else?
No response