Skip to content

Interesting E0514 error on a certain repository when running cargo clippy #100329

Open
@daniel-abramov

Description

@daniel-abramov

Bug Description

An attempt to run cargo clippy on a certain open-source repository triggers some non-obvious (weird) errors. I have never experienced such an issue before and am not sure what causes it, but it seems like other cargo tools (like build, test or check) don't exhibit such a behavior.

Basically, cargo clippy issues lots of errors like this:

error[E0514]: found crate `http` compiled by an incompatible version of rustc
   --> src/handshake/client.rs:263:35
    |
263 |         *response.version_mut() = http::Version::HTTP_11;
    |                                   ^^^^
    |
    = help: please recompile that crate using this compiler (rustc 1.64.0-nightly (4493a0f47 2022-08-02)) (consider running `cargo clean` first)
    = note: the following crate versions were found:
            crate `http` compiled by rustc 1.62.1: /Users/danielabramov/Development/Temporary/tungstenite-rs/target/debug/deps/libhttp-7678c1c40ba01260.rmeta

error[E0514]: found crate `rand` compiled by an incompatible version of rustc
   --> src/handshake/client.rs:273:23
    |
273 |     let r: [u8; 16] = rand::random();
    |                       ^^^^
    |
    = help: please recompile that crate using this compiler (rustc 1.64.0-nightly (4493a0f47 2022-08-02)) (consider running `cargo clean` first)
    = note: the following crate versions were found:
            crate `rand` compiled by rustc 1.62.1: /Users/danielabramov/Development/Temporary/tungstenite-rs/target/debug/deps/librand-150c29d9d94e1b71.rmeta

error[E0514]: found crate `base64` compiled by an incompatible version of rustc
   --> src/handshake/client.rs:274:5
    |
274 |     base64::encode(&r)
    |     ^^^^^^
    |
    = help: please recompile that crate using this compiler (rustc 1.64.0-nightly (4493a0f47 2022-08-02)) (consider running `cargo clean` first)
    = note: the following crate versions were found:
            crate `base64` compiled by rustc 1.62.1: /Users/danielabramov/Development/Temporary/tungstenite-rs/target/debug/deps/libbase64-211df52e54c0b018.rmeta

Note that the version of the compiler it suggests to use does actually match the version with which the crate was built, which confuses me. I've also tried it with rustc 1.65.0-nightly and the issue remains.

The issue only happens on M1 Macbook so far and works fine on a regular Intel Macbook as well as on Linux/PC, so I wonder if it's a target-dependent issue.

Initially I've created a bug in clippy repository. However, it was suggested, that the issue might be related to rustc or to the way clippy is interacting with rustc.

Apologies if I'm missing something and posted the issue in a wrong repository.

Reproduce

$ git clone git@github.com:snapview/tungstenite-rs.git
$ cd tungstenite-rs
$ cargo clippy

Meta

$ rustc --version --verbose
rustc 1.62.1
binary: rustc
commit-hash: unknown
commit-date: unknown
host: aarch64-apple-darwin
release: 1.62.1
LLVM version: 14.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-clippyArea: ClippyA-incr-compArea: Incremental compilationC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions