Closed
Description
When trying to write to a const array rustc does compile the code without throwing an error but does not assign the value to the array.
As an example
const FOO : [i32;1] = [0];
fn main() {
FOO[0] = 1;
println!("{:?}",FOO);
}
compiles and prints
[0]
Is this behavior intended or should the compiler stop with an error as it does when compiling the following code?
const BAR : i32 = 0;
fn main() {
BAR = 1;
println!("{:?}",BAR);
}
BAR = 1;
^^^^^^^ left-hand of expression not valid
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Relevant to the compiler team, which will review and decide on the PR/issue.