Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Rust: False positive for unused variable names

Open
#22,342 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
rust
Domain
security

Research direction

Start with the linked code-scanning alert and the Rust snippet, then trace the CodeQL Rust unused-variable query's handling of format! interpolation. Done means the query no longer reports name as unused while still detecting genuinely unused variables.

Written by the indexing model from the issue text.

Description

false-positive

Description of the false positive

CodeQL seems to produce false positives for Rust variables in format strings.

Code samples or links to source code

On 2026-08-13, the folllowing Rust snippet got flagged by CodeQL on https://github.com/alltheplaces/osm-diffs/pull/660. CodeQL posted a notice, claiming Variable 'name' is not used. However, the variable does get used in this snippet, via a format! macro. We also check for unused variables with clippy, which does not flag an unused variable for this code. So, this looks like a false positive from CodeQL.

        let producers: Vec<_> = sources
            .into_iter()
            .map(|(name, reader)| {
                let tx = tx.clone();
                s.spawn(move || -> Result<()> {
                    for record in reader.iter()? {
                        let bytes = record?;
                        let fti = FeatureToIndex::decode(bytes.as_slice()).with_context(|| {
                            format!("failed to decode a FeatureToIndex record from {name}")
                        })?;
                        tx.send(fti)?;
                        progress_bar.inc(1);
                    }
                    Ok(())
                })
            })
            .collect();

URL to the alert on GitHub code scanning (optional)

https://github.com/alltheplaces/osm-diffs/security/code-scanning/30

Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 10h
Merged PRs (30d)
134

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.

More from github/codeql

All issues in github/codeql

Similar issues

More Security issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.