Skip to content

unused_assignments not shown for vec overwrite - Rust 1.92.0-beta.3 #148960

@proski

Description

@proski

Summary

Clippy shipped with Rust 1.92.0-beta.3 doesn't report unused_assignments when a vector is initialized and then replaced with another value unconditionally.

Lint Name

unused_assignments

Reproducer

I tried this code:

fn main() {
    let mut value = b"0".to_vec();
    value = b"1".to_vec();
    println!("{:?}", value);
}

I expected to see this happen:

$ cargo +stable clippy
warning: value assigned to `value` is never read
 --> src/main.rs:2:13
  |
2 |     let mut value = b"0".to_vec();
  |             ^^^^^
  |
  = help: maybe it is overwritten before being read?
  = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

Instead, this happened:

$ cargo +beta clippy
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s

Nightly is affected too.

Version

rustc 1.92.0-beta.3 (f3f12444a 2025-11-09)
binary: rustc
commit-hash: f3f12444a017add0468f683f3a10656d29438a05
commit-date: 2025-11-09
host: x86_64-unknown-linux-gnu
release: 1.92.0-beta.3
LLVM version: 21.1.3

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.L-unused_assignmentsLint: unused_assignmentsS-has-bisectionStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions