Regression 1.91 -> 1.92: false positive unused_assignments on struct field write when raw pointer exists
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
I tried this code:
struct S {
value: u32,
}
fn main() {
let mut s = S { value: 0 };
let ptr = &raw mut s;
s.value = 42;
println!("{}", unsafe { (*ptr).value });
}
I expected to see this happen: no warnings, since s.value is read through ptr on the next line.
Instead, this happened:
warning: value assigned to `s` is never read
--> repro.rs:8:5
|
8 | s.value = 42;
| ^^^^^^^^^^^^
|
= help: maybe it is overwritten before being read?
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
warning: 1 warning emitted
The program compiles and prints 42, confirming the assignment is read through the raw pointer.
Version it worked on
It most recently worked on: Rust 1.91.0
Version with regression
rustc --version --verbose:
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-pc-windows-msvc
release: 1.92.0
LLVM version: 21.1.3
Backtrace
N/A — no crash, just a false positive lint warning.
Additional context
The false positive specifically affects struct field writes when a raw pointer to the struct has been taken via &raw mut. Direct variable writes (e.g., a = 42) have always triggered this lint in this scenario, but struct field writes (e.g., s.value = 42) were correctly suppressed through 1.91 and started falsely firing in 1.92.
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the provided reproducer with Rust 1.91.0 and 1.92.0, then investigate the unused_assignments lint handling for struct field writes when a raw pointer is created with &raw mut. Done means the 1.92 behavior no longer emits the false-positive warning while the program still prints 42, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100