Files
rust/src
Greg Miller 43eb3b9684 fix: RustcCallbacks::config() in clippy-driver
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
```
2026-02-13 14:09:51 -05:00
..