rust-lang / rust-lang/rust

false positive: variable does not need to be mutable

Open
#131,486 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lints C-bug S-needs-repro
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary

I had a false positive unused_mut, after fixing it - re-running cargo clippy still threw the warning. Seems it could have some sort of cache issue as after doing cargo clean, the lint no longer threw the warning.

Image

Lint Name

unused_mut

Reproducer

I haven't managed to reproduce this since, but just a simple:

  1. let (tx, mut rx) = mpsc::unbounded_channel();
  2. run cargo clippy
  3. remove the mut
  4. lint still remained
  5. cargo clean
  6. lint now no longer warned
Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by trying to reproduce the unused_mut warning with the reported mpsc::unbounded_channel example under rustc 1.81.0, running cargo clippy before and after removing mut and then after cargo clean. The issue provides no source file or test entry point, so first establish a reliable reproducer; done means the stale warning no longer persists after the code change without requiring cargo clean.

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
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.