From 43eb3b9684cbb01c1a99ad23d4045e7e8eaaa6f4 Mon Sep 17 00:00:00 2001 From: Greg Miller Date: Fri, 13 Feb 2026 13:49:57 -0500 Subject: [PATCH] fix: `RustcCallbacks::config()` in `clippy-driver` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `RustcCallbacks::config()` function used by `clippy-driver` was not setting `config.extra_symbols`, so when interned symbols were computed, such as `sym::CLIPPY_ARGS`, it was using some random string in the binary. The fix is to set ```rust config.extra_symbols = sym::EXTRA_SYMBOLS.into(); ``` in the config() function. This mirrors what is done in the `ClippyCallbacks::config()` function, which did not show a problem. # Steps to repro the problem (WITHOUT this PR): I'm on a mac laptop now, but I repro'd this on Linux too: ```console ❯ cargo -V cargo 1.95.0-nightly (fe2f314ae 2026-01-30) ``` 1. Create a dummy project ```console ❯ cargo new --lib /tmp/foo ``` 2. Run `clippy-driver` from this repo on `/tmp/foo/src/lib.rs`. You must specify `--cap-lints allow` in order for the `RustcCallbacks` to be used; otherwise, the `ClippyCallbacks` are used ad you won't see the problem. ```console ❯ cargo run --bin clippy-driver -- rustc --crate-name foo --edition=2024 /tmp/foo/src/lib.rs --crate-type lib --emit=dep-info --out-dir /tmp/foo --cap-lints allow ``` 3. **The problem**: The problem is the `env-dep:macos` line. It is _incorrectly_ recording that the "macos" environment varialbe is relevant for this build. On Linux it showed the string "linux". I've also seen other random strings, like "128". I believe these strings are arbitrary. The problem is that the `sym::CLIPPY_ARGS` symbol is read without the `exta_symbols` table being set. ```console ❯ cat /tmp/foo/foo.d /tmp/foo/foo.d: /tmp/foo/src/lib.rs /tmp/foo/src/lib.rs: # env-dep:macos ``` # The fix: With this fix in this PR, we can re-run the `clippy-driver` invocation in step 2 above and see the expected dep-info showing `env-dep:CLIPPY_ARGS` instead of `env-dep:macos`. ```console ❯ cargo run --bin clippy-driver -- rustc --crate-name foo --edition=2024 /tmp/foo/src/lib.rs --crate-type lib --emit=dep-info --out-dir /tmp/foo --cap-lints allow ❯ cat /tmp/foo/foo.d /tmp/foo/foo.d: /tmp/foo/src/lib.rs /tmp/foo/src/lib.rs: # env-dep:CLIPPY_ARGS ``` --- src/driver.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/driver.rs b/src/driver.rs index 409eb182fe33..f27cb6708709 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -126,6 +126,7 @@ fn config(&mut self, config: &mut interface::Config) { config.psess_created = Some(Box::new(move |psess| { track_clippy_args(psess, clippy_args_var.as_deref()); })); + config.extra_symbols = sym::EXTRA_SYMBOLS.into(); } }