Open
Description
I tried this code:
pub struct MaxLengthString<const N: u8> {
len: u8,
buf: [u8; N],
}
And I got this compilation error:
error[E0308]: mismatched types
--> src/lib.rs:3:15
|
3 | buf: [u8; N],
| ^ expected `usize`, found `u8`
For more information about this error, try `rustc --explain E0308`.
This works fine if the const parameter is of type usize
, but I think it should work for the other unsigned types that are smaller than usize
. Or at the very least, maybe there should be a different error message that says this is definitely not supported.
Meta
rustc --version --verbose
:
rustc 1.67.0-nightly (8681d4cff 2022-11-25)
binary: rustc
commit-hash: 8681d4cffcd23bbe619984ab62772a91827a40dc
commit-date: 2022-11-25
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4
Metadata
Metadata
Assignees
Labels
Area: `[T; N]`Area: const generics (parameters and arguments)Area: Messages for errors, warnings, and lintsDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Status: Blocked on something else such as an RFC or other implementation work.Relevant to the compiler team, which will review and decide on the PR/issue.