Rust: False positive for unused variable names

オープン
#22,342 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
静か
技術スタック
rust
領域
security

調査の方向性

リンクされたコードスキャンアラートと Rust スニペットから始め、次に CodeQL Rust 未使用変数クエリが format! の補間をどのように処理しているかを追跡します。クエリが name を未使用として報告しなくなり、同時に実際に未使用の変数は引き続き検出できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 11時間
マージ済み PR(30日)
129

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql のほかの issue

github/codeql の issue をすべて見る

似ている issue

Security の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。