rust-lang / rust-lang/rust-clippy

used_unused_variable lint

Open
#4,239 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint L-suggestion
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

The idea is to lint for variables that have had a _ prepended on them to avoid unused variable lints and then subsequently been used.

The motivation for this change is that I want to use cargo fix --clippy as my default command to run to check my working copy for compiler errors, but it puts _ on the front of variables when I'm initially writing them and then doesn't clean up after itself once I start using said variables. This bothers me and I want to fix it to make my workflow smoother.

We would want to restrict this lint by default, a its entirely reasonable to start variables with an underscore normally, so we don't necessarily want to force people to treat a leading _ as a reserved that they can't use except to indicate a variable is unused.

For this to be useful for my workflow the lint should be marked as MachineApplicable.

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

No file or test is named in the issue. Start by locating Clippy's existing handling for unused-variable lints, then determine how to detect underscore-prefixed variables that are later used and how lint applicability is represented. Done means a restricted lint identifies those variables, provides a MachineApplicable fix, and has tests covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.