No compiler error when attempting to change field of const struct #49974
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
There is no compiler error, when trying to change the field of a
const
struct.I tried this code:
I expected to see this happen:
Compiler error, because I try to change the value of a
const
.Instead, this happened:
The statement is just ignored.
A.a = 10;
looks like the value ofA.a
is set to10
, since there is no compiler error, I expect this to happen.Instead when printing the value of
A.a
, it is still the initial value0
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: