rust-lang / rust-lang/rust-clippy
Clippy can run the wrong rustc, leading to "incompatible version of rustc" errors
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
I had several versions of Rust installed (via rustup) and was surprised that Clippy would sometimes give errors like this:
error[E0514]: found crate `paste` compiled by an incompatible version of rustc
...
= help: please recompile that crate using this compiler (rustc 1.64.0 ...)
= note: the following crate versions were found:
crate `paste` compiled by rustc 1.63.0: ...
1.64.0 was in fact the version I wanted to be using.
The surprise came when I did rustup toolchain remove 1.63.0, then cargo clean && cargo clippy, and still got the same error!
It turns out I had yet another copy of Rust 1.63.0 installed, via Homebrew, as /usr/local/bin/rustc.
I think I must have done brew install rust-analyzer at some point and that brought in the rust package.
Obviously that was bad and I just removed it. But this means cargo clippy sometimes results in two different rustc executables being used. I think that must be a bug.
Reproducer
Possible steps to reproduce, using code in https://github.com/jorendorff/incompavers:
-
Run these commands:
brew install rust git clone https://github.com/jorendorff/incompavers.git cd incompavers cargo clean && cargo clippy --verbose
Expected behavior: Clippy should lint the crate.
Actual behavior: Clippy produced the errors below.
❯ cargo clean && cargo clippy --verbose
Checking base64 v0.13.0
Compiling paste v1.0.9
Running `rustc --crate-name base64 --edition=2018 /Users/jorendorff/.cargo/registry/src/github.com-1ecc6299db9ec823/base64-0.13.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=bd37c0a895c55f89 -C extra-filename=-bd37c0a895c55f89 --out-dir /Users/jorendorff/src/incompavers/target/debug/deps -L dependency=/Users/jorendorff/src/incompavers/target/debug/deps --cap-lints allow`
Running `rustc --crate-name paste --edition=2018 /Users/jorendorff/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.9/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=1cc8d85ad06b00de -C extra-filename=-1cc8d85ad06b00de --out-dir /Users/jorendorff/src/incompavers/target/debug/deps -L dependency=/Users/jorendorff/src/incompavers/target/debug/deps --extern proc_macro --cap-lints allow`
Checking incompavers v0.1.0 (/Users/jorendorff/src/incompavers)
Running `/Users/jorendorff/.rustup/toolchains/stable-x86_64-apple-darwin/bin/clippy-driver rustc --crate-name incompavers --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=8f4097126ae0e3f7 -C extra-filename=-8f4097126ae0e3f7 --out-dir /Users/jorendorff/src/incompavers/target/debug/deps -C incremental=/Users/jorendorff/src/incompavers/target/debug/incremental -L dependency=/Users/jorendorff/src/incompavers/target/debug/deps --extern base64=/Users/jorendorff/src/incompavers/target/debug/deps/libbase64-bd37c0a895c55f89.rmeta --extern paste=/Users/jorendorff/src/incompavers/target/debug/deps/libpaste-1cc8d85ad06b00de.dylib`
error[E0514]: found crate `paste` compiled by an incompatible version of rustc
--> src/lib.rs:1:9
|
1 | pub use paste::paste;
| ^^^^^
|
= help: please recompile that crate using this compiler (rustc 1.64.0 (a55dd71d5 2022-09-19)) (consider running `cargo clean` first)
= note: the following crate versions were found:
crate `paste` compiled by rustc 1.63.0: /Users/jorendorff/src/incompavers/target/debug/deps/libpaste-1cc8d85ad06b00de.dylib
error[E0514]: found crate `base64` compiled by an incompatible version of rustc
--> src/lib.rs:22:26
|
22 | println!("hello {}", base64::encode(b"world"));
| ^^^^^^
|
= help: please recompile that crate using this compiler (rustc 1.64.0 (a55dd71d5 2022-09-19)) (consider running `cargo clean` first)
= note: the following crate versions were found:
crate `base64` compiled by rustc 1.63.0: /Users/jorendorff/src/incompavers/target/debug/deps/libbase64-bd37c0a895c55f89.rmeta
error: could not compile `incompavers` due to 2 previous errors
Caused by:
process didn't exit successfully: `/Users/jorendorff/.rustup/toolchains/stable-x86_64-apple-darwin/bin/clippy-driver rustc --crate-name incompavers --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=8f4097126ae0e3f7 -C extra-filename=-8f4097126ae0e3f7 --out-dir /Users/jorendorff/src/incompavers/target/debug/deps -C incremental=/Users/jorendorff/src/incompavers/target/debug/incremental -L dependency=/Users/jorendorff/src/incompavers/target/debug/deps --extern base64=/Users/jorendorff/src/incompavers/target/debug/deps/libbase64-bd37c0a895c55f89.rmeta --extern paste=/Users/jorendorff/src/incompavers/target/debug/deps/libpaste-1cc8d85ad06b00de.dylib` (exit status: 1)
Version
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-apple-darwin
release: 1.64.0
LLVM version: 14.0.6
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with cargo clean && cargo clippy --verbose using both rustup and Homebrew Rust installations. Inspect the reported clippy-driver, rustc, and toolchain paths to determine where the executables diverge. Done means the reproducer lints successfully without incompatible-rustc errors when the selected rustup toolchain is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100