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

"error[E0519]: the current crate is indistinguishable from one of its dependencies" does not always accurately describe the problem #111691

Open
bridiver opened this issue May 17, 2023 · 6 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-metadata Area: Crate metadata C-bug Category: This is a bug.

Comments

@bridiver
Copy link

bridiver commented May 17, 2023

We were seeing error[E0519]: the current crate is indistinguishable from one of its dependencies in our build and couldn't really make sense of it because it was complaining about things like log crate inside html5ever. It turns out that chromium added https://source.chromium.org/chromium/chromium/src/+/main:build/rust/cargo_crate.gni;l=102?q=rustc_metadata&ss=chromium

_rustc_metadata = ""
  if (defined(invoker.rustc_metadata)) {
    _rustc_metadata = invoker.rustc_metadata
  } else if (defined(invoker.epoch)) {
    _rustc_metadata = invoker.epoch
  }

which defaults to using the epoch in -Cmetadata=${_rustc_metadata}
If you happen to have two different crates with the same symbol and same epoch (but different crate names), you'll get this error, but the description of the problem is confusing because it actually has nothing to do with crate names in this case it has the same crate-name log and was compiled with the same -C metadata arguments
The crate name appears to be irrelevant if you supply the same metadata arguments because we fixed it with this

_metadata = "0"
  if (defined(invoker.epoch)) {
    _metadata = invoker.epoch
  }
  if (defined(invoker.crate_name)) {
    _metadata += invoker.crate_name
  }
@bridiver bridiver added the C-bug Category: This is a bug. label May 17, 2023
@rillian
Copy link
Contributor

rillian commented May 17, 2023

If I understand the issue correctly, the chromium build system is calling rustc with something like -C metadata=0.25 derived from the crate minor version, where cargo has a longer hash. This causes collisions for symbols defined in dependencies which happened to have the same version number. That is just an issue with how the compiler is invoked. So far so good.

However, like with #111284, the error message reported by the compiler was a bit indirect. It would be nice if it suggested e.g. to check for the crates built with the same -C metadata. Maybe especially if it doesn't look like what cargo supplies, or if the compiler can determine the indistinguishable crates have the same metadata tag?

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints A-metadata Area: Crate metadata labels May 31, 2023
@riking
Copy link

riking commented Jun 6, 2023

Bad error message selectoin was fixed in #111461

@icmccorm
Copy link

icmccorm commented Jun 19, 2023

I'm also seeing this issue when I attempt to compile rustc with address sanitizer enabled. I'm using a nightly toolchain with -Zsanitizer=address instead of downloading the stage0 binaries. Switching between old and recent nightly toolchains, I see both the old message—the current crate is indistinguishable...—as well as the new message, can't find crate. Both are referring to clap_derive. If I remove -Zsanitizer=address, everything compiles just fine.

@barafael
Copy link

I'm seeing this issue when compiling my crate for coverage analysis using cargo-tarpaulin.

@misha-antonenko
Copy link

misha-antonenko commented Sep 30, 2023

The problem described by @icmccorm also reproduces with -Zsanitizer=thread

Upd: maybe the reason is in missed -Zbuild-std, as here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-metadata Area: Crate metadata C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

7 participants