-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Const generics: Generic array transmutes do not work #61956
Copy link
Copy link
Closed
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
This trivial transmute should work:
Unfortunately, it refuses to build with the following error:
This means that the array initialization example from the
core::mem::MaybeUninitdocumentation currently cannot be generalized to arrays of arbitrary size, as transmutes from[MaybeUnit<T>; N]to[T; N]won't compile.A horribly error-prone workaround for generic array transmute is: