-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-sliceArea: `[T]`Area: `[T]`D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.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
Given the following code (playground):
const _SEASONS : [&str] = ["Winter", "Spring", "Summer", "Fall"];
The current output is:
error[E0277]: the size for values of type `[&'static str]` cannot be known at compilation time
--> src/lib.rs:1:18
|
1 | const _SEASONS : [&str] = ["Winter", "Spring", "Summer", "Fall"];
| ^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[&'static str]`
Ideally the output should make it clearer why this is an error, and suggest a fix:
error: constant items must have a size known at compile-time
help: provide a length for the constant array: `[&str; 4]`
Note that if I omit the type entirely (playground):
const _SEASONS = ["Winter", "Spring", "Summer", "Fall"];
I do get an error message that suggests the correct array type:
error: missing type for `const` item
--> src/lib.rs:1:15
|
1 | const _SEASONS = ["Winter", "Spring", "Summer", "Fall"];
| ^ help: provide a type for the constant: `: [&str; 4]`
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-sliceArea: `[T]`Area: `[T]`D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.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.