Skip to content

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

@bridiver

Description

@bridiver

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
  }

Activity

rillian

rillian commented on May 17, 2023

@rillian
Contributor

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?

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-metadataArea: Crate metadata
on May 31, 2023
riking

riking commented on Jun 6, 2023

@riking

Bad error message selectoin was fixed in #111461

icmccorm

icmccorm commented on Jun 19, 2023

@icmccorm

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

barafael commented on Aug 25, 2023

@barafael
Contributor

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

misha-antonenko

misha-antonenko commented on Sep 30, 2023

@misha-antonenko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-metadataArea: Crate metadataC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bridiver@rillian@riking@barafael@misha-antonenko

        Issue actions

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