-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Const-generic type mismatch: #[repr(usize)] enum as const parameter in arrays #61522
Comments
Not sure where you see the ICE, removing that. |
This is glitch after the previous 2 issues.. It is not ICE. |
To @varkor Minimal code: #![feature(const_generics)]
pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
impl<const COUNT: usize> MyArray<{COUNT}> {
fn inner(&self) -> &[u8; COUNT + 1] {
&self.0
}
}
fn main() {
} produce error: error[E0308]: mismatched types
--> src/main.rs:8:9
|
8 | &self.0
| ^^^^^^^ expected `COUNT + 1`, found `COUNT + 1`
|
= note: expected type `&[u8; _]`
found type `&[u8; _]` The |
Now it is ICE:
|
It's back to the original error. |
Now it produce this errors:
|
The behaviour is now as expected. We just need a test now. |
Const Generic RFC leads the code as possible:
Is there another issue that is tracking it? |
Yes, there are some subtle issues about making sure that constants in types are well-formed. The tracking issue for this is #68436. |
The code:
It produced error:
Playground
Although Constants in array repeat expressions RFC not yet implemented, this code must work already.
Or I'm wrong and this syntax does not supported by const-generics?
The text was updated successfully, but these errors were encountered: