-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Allow renaming crates in the dependencies section #1311
Comments
What's the intent of this? What would it do differently than: [dependencies]
rustc-serialize = "*" |
This is actually currently possible as: [dependencies.foo]
version = "..." Although if you mean renaming crates that's a separate issue :) |
@alexcrichton I do mean renaming crates, please re-open :P @tomjakubowski It would create a crate named |
(updated with what I believe to be a more accurate title) |
Sure, this title works. But a side effect of this is to permit the specification of crates.io as the origin of a dependency named in its own subsection (like |
This is a wanted feature for the following scenario: Your crate provides an optional feature named "serde" that enables serde integration. In the next version you want to depend two crates for the "serde" feature, serde itself and another crate. Renaming the serde dependency would make the serde feature name available to do this transition smoothly. |
Yes, it's considering the same kinds of questions I have (but in greater depth). |
Someone was trying to depend on both |
Another example: a program that compared gif implementations might want to use both https://github.com/Geal/gif.rs/blob/master/Cargo.toml and https://github.com/PistonDevelopers/image-gif/blob/master/Cargo.toml, both of which claim the name "gif". |
I've been having a think about this lately, and wondering the best way to do this... it seems the crate name (the one used in |
FWIW I have a PR open for this, and any comments would be much appreciated! |
@alexcrichton Doh, I wish I had known sooner! I just implemented it here too. Oh well, at least someone has done it. Thanks. |
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! cc #1311
@alexcrichton I think this should be closed now that #4953 is merged, no? |
Indeed! |
The example in #4953 fails with:
|
@dragostis could you open a separate issue for that, so that this does not fall through the cracks? |
cc #5413 |
Something like this should work:
At the moment, only
path
andgit
attributes are supported.The text was updated successfully, but these errors were encountered: