Skip to content

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

Open
@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
  }

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

    Issue actions