Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple matching crates for rustc_serialize panic #1638

Closed
gibfahn opened this issue Mar 26, 2017 · 10 comments · Fixed by #1640
Closed

multiple matching crates for rustc_serialize panic #1638

gibfahn opened this issue Mar 26, 2017 · 10 comments · Fixed by #1640

Comments

@gibfahn
Copy link
Contributor

gibfahn commented Mar 26, 2017

Minimal repro:

#![feature(rustc_private)]
extern crate rustc_serialize;
use rustc_serialize::hex::ToHex;

fn main() {
    println!("Use toHex: {}", [0xFF_u8].to_hex());
}
  • rustc: nightly-x86_64-apple-darwin - rustc 1.17.0-nightly (49c67bd63 2017-03-24)
  • clippy v0.0.121

Error:

➜ cargo clippy
   Compiling clippy_panic v0.1.0 (file:///Users/gib/tmp/clippy_panic)
error[E0464]: multiple matching crates for `rustc_serialize`
 --> src/main.rs:2:1
  |
2 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: candidates:
  = note: path: /Users/gib/tmp/clippy_panic/target/debug/deps/librustc_serialize-54d2bf33b1d4b0b0.rlib
  = note: crate name: rustc_serialize
  = note: path: /Users/gib/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_serialize-fde13340fc7641e7.rlib
  = note: crate name: rustc_serialize

error[E0463]: can't find crate for `rustc_serialize`
 --> src/main.rs:2:1
  |
2 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:455
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'main' panicked at 'rustc_thread failed: Any', src/libcore/result.rs:859
error: Could not compile `clippy_panic`.

To learn more, run the command again with --verbose.
  = note: path: /Users/gib/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_serialize-fde13340fc7641e7.rlib
  = note: crate name: rustc_serialize

error[E0463]: can't find crate for `rustc_serialize`
 --> src/main.rs:3:1
  |
3 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:455
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'main' panicked at 'rustc_thread failed: Any', src/libcore/result.rs:859
error: Could not compile `five`.

To learn more, run the command again with --verbose.
@Manishearth
Copy link
Member

You should delete the build directory.

@gibfahn
Copy link
Contributor Author

gibfahn commented Mar 26, 2017

Okay, that works for my (I guess too-minimal) test case, but not for the app I originally had the problem with, as that one also uses the crypto crate (looks like that depends on the external rustc-serialize).

Cargo.toml:

[dependencies]
rust-crypto = "^0.2"

Cargo.lock (relevant lines)

[[package]]
name = "rust-crypto"
version = "0.2.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "gcc 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
 "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
 "rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
 "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rustc-serialize"
version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index"

Output

➜ rm -rf target && cargo clippy                                                                                                                                            ~/tmp/clippy_panic
   Compiling rustc-serialize v0.3.23
   Compiling gcc v0.3.45
   Compiling libc v0.2.21
   Compiling time v0.1.36
   Compiling rand v0.3.15
   Compiling rust-crypto v0.2.36
   Compiling five v0.1.0 (file:///Users/gib/tmp/clippy_panic)
error[E0464]: multiple matching crates for `rustc_serialize`
 --> src/main.rs:2:1
  |
2 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: candidates:
  = note: path: /Users/gib/tmp/clippy_panic/target/debug/deps/librustc_serialize-54d2bf33b1d4b0b0.rlib
  = note: crate name: rustc_serialize
  = note: path: /Users/gib/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_serialize-fde13340fc7641e7.rlib
  = note: crate name: rustc_serialize

error[E0463]: can't find crate for `rustc_serialize`
 --> src/main.rs:2:1
  |
2 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:455
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'main' panicked at 'rustc_thread failed: Any', src/libcore/result.rs:859
error: Could not compile `five`.

To learn more, run the command again with --verbose.

@oli-obk oli-obk reopened this Mar 26, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2017

Does building with cargo rustc work? I don't think cargo clippy does anything special.

@gibfahn
Copy link
Contributor Author

gibfahn commented Mar 27, 2017

Yep, building works fine:

➜  clippy_panic git:(master) cargo run                                                                            ~/tmp/clippy_panic
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/clippy_panic`
Use toHex: ff

I made a repo for the source in case you wanted to try it out: https://github.com/gibfahn/clippy-panic

cargo clippy fails consistently for me.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2017

cargo rustc works differently from cargo run! We forward to cargo rustc, so if cargo rustc also fails, we can't do anything about it.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2017

I made a repo for the source in case you wanted to try it out: https://github.com/gibfahn/clippy-panic

Thanks, trying it now

@gibfahn
Copy link
Contributor Author

gibfahn commented Mar 27, 2017

Oh sorry, I assumed cargo build called cargo rustc behind the scenes. cargo rustc also passes:

➜  clippy_panic git:(master) cargo rustc                                                                          ~/tmp/clippy_panic
   Compiling libc v0.2.21
   Compiling gcc v0.3.45
   Compiling rustc-serialize v0.3.23
   Compiling rand v0.3.15
   Compiling time v0.1.36
   Compiling rust-crypto v0.2.36
   Compiling clippy_panic v0.1.0 (file:///Users/gib/tmp/clippy_panic)
    Finished dev [unoptimized + debuginfo] target(s) in 11.20 secs

@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2017

We additionally pass -L target/debug/deps -Zno-trans --cfg 'feature="cargo-clippy"' to the cargo rustc call. The -L is the cause most likely. Looks like a legacy thing. I'll check if we can remove it.

@gibfahn
Copy link
Contributor Author

gibfahn commented Mar 27, 2017

That seems like the issue, cargo rustc passes, but:

cargo rustc -- -L target/debug/deps -Zno-trans --cfg 'feature="cargo-clippy"' 

Fails with the above error.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 27, 2017

It's a remnant from the time when we needed the clippy plugin to run cargo clippy. Nowadays cargo-clippy contains all the lints itself and injects them into the rustc call.

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 a pull request may close this issue.

3 participants