Skip to content

Use RUSTC_WRAPPER so AllCrates also runs on dependencies - #46

Open
konstde00 wants to merge 1 commit into
cognitive-engineering-lab:mainfrom
konstde00:all-crates-rustc-wrapper
Open

konstde00 wants to merge 1 commit into
cognitive-engineering-lab:mainfrom
konstde00:all-crates-rustc-wrapper

Conversation

@konstde00

Copy link
Copy Markdown

CrateFilter::AllCrates never runs the plugin on dependencies. cli_main always sets RUSTC_WORKSPACE_WRAPPER (cli.rs:46), and Cargo applies that wrapper only to workspace members, so dependencies are compiled by plain rustc and never reach the run_on_all_crates check in the driver (driver.rs:134-141).

For AllCrates the CLI now sets RUSTC_WRAPPER instead, while OnlyWorkspace and CrateContainingFile keep RUSTC_WORKSPACE_WRAPPER. The driver doesn't need to change, because Cargo passes the rustc path as the first argument with either variable, and wrapper_mode already strips it. With RUSTC_WRAPPER the plugin also runs on build scripts and proc-macro crates of dependencies, and a wrapper the user set themselves (sccache, for example) gets replaced during AllCrates runs.

Tests

  • New dependency test on workspaces/deps, a crate whose path dependency is not a workspace member. On main it fails because only the root crate's items are printed. With this change it passes.
  • cargo clippy --all-features -- -D warnings, cargo test --all-features -- --test-threads=1, cargo doc with -D warnings and cargo fmt --all --check pass locally on nightly-2026-05-01 and in CI on my fork: https://github.com/konstde00/rustc_plugin/actions/runs/40108212927
  • By hand: cargo print-all-items on a new crate that depends on itoa printed 3 items before and 69 after, including itoa's Buffer and Integer.

Fixes #19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin CLI does not respect the AllCrates filter

1 participant