False positive warning from dereference-assignment of const pointer to mutable data #77321
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I have quite a lot of MMIO in an embedded project, defined and used like this:
(see a playground link)
When I
cargo build
, I'm getting a whole host of warnings of the type:I expect no warnings, because I'm not assigning to a
const
, I'm assigning to a dereferenced*mut u32
, aka a mutable u32.I couldn't figure out a playground example that would show the value actually mutating, but by hitting hardware registers I can prove that the value does get mutated, and it makes sense that it would: The pointer is
const
, but it's pointing to amut
ableu32
. Dereferencing shouldn't care whether the pointer variable isconst
.Meta
rustc --version --verbose
:No backtrace for this bug; it's a warning.
The text was updated successfully, but these errors were encountered: