Dependency specificiation with git and version + registry

Hello!

According to the Multiple Locations session of the cargo reference, it is possible to define both git and version locations when specifying a dependency.

It is not possible though, to add a registry to the version, so for instance:

# Works fine
my-dependency = {"version" = "1.0", git = "my-repo", branch = "my-branch"}

# Errors with message: "Only one of `git` or `registry` is allowed."
my-dependency = {"version" = "1.0", registry = "my-registry", git = "my-repo", branch = "my-branch"}

There is nothing that I could find about this in the cargo documentation link above, and it is not clear to me why this is not allowed if it works for "crates.io". Any thoughts?

Thank you!

That's just how the check is implemented:

It has special handling for crates.io, but not other registries:

I don't know if that's intentional (just allowing crates.io for backwards compat), or an oversight/bug.

Hi @kornel, thanks for the reply and the reference!

Backwards compatibility make sense

I still find it a bit weird that there is no documentation about this anywhere, though, and even the way it is written in the docs is misleading in my opinion:

... and when published to a registry like crates.io, it will use the registry version.

I might ask this question in the Github repository to see if it is an oversight or backwards compat and get more context on the reasoning behind the implementation