-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.
Description
The following code:
fn uwu<const N: usize>() {
let _ = [0; N{}];
}produces the error
error: generic parameters may not be used in const operations
--> src/lib.rs:2:17
|
2 | let _ = [0; N{}];
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
however, when enabling feature(generic_const_exprs), the error changes to
error[[E0574]](https://doc.rust-lang.org/nightly/error_codes/E0574.html): expected struct, variant or union type, found const parameter `N`
--> src/lib.rs:4:17
|
4 | let _ = [0; N{}];
| ^ not a struct, variant or union type
The error on stable should change to be the same as the error with generic_const_exprs enabled.
On stable, it's probably more likely that the user doesn't want the generic to be const, or wants to remove the {} than them trying to actually do anything with generic_const_exprs.
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.