You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
const_item_mutation incorrectly fires when using raw pointers #78819
I expected to see this happen: This should compile without warnings, as I am just turning the 0x8000_0000 raw pointer into a mutable reference.
Instead, this happened:
warning: taking a mutable reference to a `const` item
--> src/main.rs:4:14
|
4 | unsafe { &mut *PTR };
| ^^^^^^^^^
|
= note: `#[warn(const_item_mutation)]` on by default
= note: each usage of a `const` item creates a new temporary
= note: the mutable reference will refer to this temporary, not the original `const` item
note: `const` item defined here
--> src/main.rs:2:5
|
2 | const PTR: *mut () = 0x8000_0000 as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The lint claims that I'm "taking a mutable reference to a const item", but I'm not – the const item is the reference.
This warning started popping up a lot for the cortex-m crate, which uses this pattern heavily.
Activity
Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref
Rollup merge of rust-lang#78865 - Aaron1011:fix/const-item-mut-reborr…