Implement renaming dependencies in the manifest
authorAlex Crichton <alex@alexcrichton.com>
Wed, 17 Jan 2018 19:33:25 +0000 (11:33 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 12 Feb 2018 23:15:39 +0000 (15:15 -0800)
commit79942fea1bb7a480f6eebd6cd1f8a04ac9f45a0b
treea89cbb4d3cab601b448ad7c7342f468722d9ad1b
parentcb30fba4a35d8716ed490cc9a220ae99701d8015
Implement renaming dependencies in the manifest

This commit implements a new unstable feature for manifests which allows
renaming a crate when depending on it. For example you can do:

```toml
cargo-features = ["dependencies-as"]

...

[dependencies]
foo = "0.1"
bar = { version = "0.1", registry = "custom", package = "foo" }
baz = { git = "https://github.com/foo/bar", package = "foo" }
```

Here three crates will be imported but they'll be made available to the Rust
source code via the names `foo` (crates.io), `bar` (the custom registry), and
`baz` (the git dependency). The *package* name, however, will be `foo` for all
of them. In other words the git repository here would be searched for a crate
called `foo`. For example:

```rust
extern crate foo; // crates.io
extern crate bar; // registry `custom`
extern crate baz; // git repository
```

The intention here is to enable a few use cases:

* Enable depending on the same named crate from different registries
* Allow depending on multiple versions of a crate from one registry
* Removing the need for `extern crate foo as bar` syntactically in Rust source

Currently I don't think we're ready to stabilize this so it's just a nightly
feature, but I'm hoping we can continue to iterate on it!
src/cargo/core/dependency.rs
src/cargo/core/features.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/util/toml/mod.rs
tests/metadata.rs
tests/rename-deps.rs [new file with mode: 0644]