Change:
= note: `#[warn(const_item_mutation)]` on by default = note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified note: `const` item defined here <del> --> $DIR/lint-const-item-mutation.rs:11:1 </del> <ins> --> $DIR/lint-const-item-mutation.rs:12:1 </ins> | LL | const ARRAY: [u8; 1] = [25]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: attempting to modify a `const` item <del> --> $DIR/lint-const-item-mutation.rs:16:5 </del> <ins> --> $DIR/lint-const-item-mutation.rs:18:5 </ins> | LL |     MY_STRUCT.field = false; |     ^^^^^^^^^^^^^^^^^^^^^^^ | = note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified note: `const` item defined here <del> --> $DIR/lint-const-item-mutation.rs:12:1 </del> <ins> --> $DIR/lint-const-item-mutation.rs:13:1 </ins> | <del> LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ </del> <ins> LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ </ins> warning: attempting to modify a `const` item <del> --> $DIR/lint-const-item-mutation.rs:17:5 </del> <ins> --> $DIR/lint-const-item-mutation.rs:19:5 </ins> | LL |     MY_STRUCT.inner_array[0] = 'b'; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified note: `const` item defined here <del> --> $DIR/lint-const-item-mutation.rs:12:1 </del> <ins> --> $DIR/lint-const-item-mutation.rs:13:1 </ins> | <del> LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ </del> <ins> LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ </ins> warning: taking a mutable reference to a `const` item <del> --> $DIR/lint-const-item-mutation.rs:18:5 </del> <ins> --> $DIR/lint-const-item-mutation.rs:20:5 </ins> | LL |     MY_STRUCT.use_mut(); |     ^^^^^^^^^^^^^^^^^^^

Discussion:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. --I have quite a lot of MMIO in an embedded project, defined and used like this: (see a ) When I , I'm getting a whole host of warnings of the type: I expect no warnings, because I'm not assigning to a , I'm assigning to a dereferenced , 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 , but it's pointing to a able . Dereferencing shouldn't care whether the pointer variable is . <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: No backtrace for this bug; it's a warning.
There's a... fine, I guess, workaround of in my case, since all the MMIO code is bundled into a module away from the rest.
cc
This will be fixed by
Awesome, thanks so much!