Confusing error message combining when arrays, size_of in a container #75678
Labels
A-const-generics
Area: const generics (parameters and arguments)
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ff721dd90338cf7cfa30b9fe7198db36
This code tries to use
[u8; std::mem::size_of::<T>()]
, where T is generic parameter. This is currently not supported, so forgood
function compiler gives helpful error:constant expression depends on a generic parameter
.However, for functions
bad1
andbad2
(where ill-formed array declaration is wrapped into other type), compiler gives errorthe size for values of type
Tcannot be known at compilation time
. Furthermore, it suggests to addSized
bound, while it is already specified. I think this message and suggestion can be confusing.Meta
I used rust v1.45.2 on the Rust Playground.
The text was updated successfully, but these errors were encountered: