Closed
Description
#![feature(min_const_generics)]
fn test<T>() -> [u8; std::mem::size_of::<T>()] {
todo!()
}
emits
error: generic parameters must not be used inside of non trivial constant values
--> src/lib.rs:3:42
|
3 | fn test<T>() -> [u8; std::mem::size_of::<T>()] {
| ^ non-trivial anonymous constants must not depend on the parameter `T`
|
= help: it is currently only allowed to use either `T` or `{ T }` as generic constants
The help is incorrect here, as type parameters in constants are not supported at all with min_const_generics
.
The error is emitted here
rust/compiler/rustc_resolve/src/diagnostics.rs
Lines 469 to 485 in b5f55b7
We probably want to change ParamInNonTrivialAnonConst
to instead contain an Option
which is only Some
for const parameters.
For type parameters we can instead emit a note saying
note: type parameters are currently not permitted in anonymous constants
If you need more help feel free to ask either here on on zulip.
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.An error is correctly emitted, but is confusing, for `min_const_generics`.