Rust: extraction succeeds with missing proc-macro output when the project's `rust-version` exceeds the forced toolchain
メンテナーはふだん 1 日以内に返信
@paldepind がすでに取り組んでいます。
2026年10月9日 から。
評価
この issue はまだ評価されていません。
説明
Description of the issue
Since the Rust extractor began forcing FIXED_RUST_TOOLCHAIN (d9417a34, first shipped in CodeQL 2.27.1), a project whose Cargo.toml declares a rust-version newer than that toolchain loses its build-script outputs and procedural-macro expansions during extraction.
get_extra_env() in rust/extractor/src/config.rs sets RUSTUP_TOOLCHAIN to the fixed toolchain after merging cargo_extra_env, so the build-script cargo check that rust-analyzer runs uses that toolchain. Cargo refuses the package because its declared rust-version is newer than the active compiler. load_workspace_at in ra_ap_load_cargo logs the error at debug level and continues loading the workspace.
The analysis reports success. Macro-expansion warnings appear in the extraction output, but the underlying Cargo refusal is hidden by the default logging filter, which does not include rust-analyzer's targets.
Because the fixed toolchain trails the latest stable release, a project can be affected whenever its declared minimum exceeds the extractor's selected compiler. Cargo's documentation describes tracking the latest Rust version as one valid rust-version policy, and projects following it will be affected after a stable release until the extractor's toolchain catches up. The open rust-analyzer updates (#22741, #22776) move the fixed toolchain to 1.99.0, which would cover this project's current declaration but not the next stable release.
Evidence
Environment: CodeQL CLI 2.27.1 (FIXED_RUST_TOOLCHAIN = "1.97.0"), github/codeql-action v4.38.2, build-mode: none, ubuntu-latest. The project pins 1.99.0 in rust-toolchain.toml and declares rust-version = "1.99.0".
With RUST_LOG enabling ra_ap_load_cargo=debug, rust-analyzer logs the refusal:
Errors occurred while running build scripts for .../backend/Cargo.toml: error: rustc 1.97.0 is not supported by the following packages:
[email protected] requires rustc 1.99.0
To confirm the cause, two runs were made on the same revision, differing only in whether CODEQL_EXTRACTOR_RUST_OPTION_CARGO_EXTRA_ARGS=--ignore-rust-version was set. Each queried the finished database for first-party macro expansions:
| Measure | Without the flag | With the flag |
|---|---|---|
Build-script/proc-macro outputs loaded (BuildScriptOutput entries) |
0 | 83 |
| "proc-macro not yet built" diagnostics | 317 | 0 |
| "macro expansion failed" diagnostics (capped per file) | 128 | 0 |
sqlx expand_query calls expanding to more than five AST nodes |
0 of 308 | 308 of 308 |
| Derive expansions containing items | 587 of 904 | 1,059 of 1,059 |
| Attribute-macro expansions containing items | 0 | 96 |
Job logs, including the database query output:
- Without the flag: https://github.com/unkos-dev/reverie/actions/runs/37893162409/job/113698447396
- With the flag: https://github.com/unkos-dev/reverie/actions/runs/37894117181/job/113701453702
The flag only skips Cargo's version check. It would not help if a build script or procedural-macro dependency genuinely required a newer compiler than the forced toolchain, and cargo_extra_args is not part of the published option schema in rust/codeql-extractor.yml.
Related: #19982 (macro expansion warnings), #22493 (pinning the toolchain).
- 主要言語
- CodeQL
- スター
- 10.2k
- フォーク
- 2.1k
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 155
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/codeql のほかの issue
-
false-positive javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
github/codeql#22632 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)対応中かも @cnuss が 193 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/codeql#21637 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
false-positive
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
github/codeql#21076 · コメント 3 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
-
Actions: `uses: $/…` self-repository references are not resolved to local reusable workflows or composite actions (false positives and downgraded severity)対応中かも @WilliamBerryiii が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
github/codeql#22755 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信