-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo add
disables previously enabled features when converting between _
and -
#10680
Comments
What's happening is that the name as it exists on the command line was not found in the manifest, so we think its a new dependency and look it up in the registry. We do a fuzzy look up in the registry so that it will canonicalize it which causes it to match with an entry in the manifest and overwrites it. Preferably we would not disable the canonicalization but extend it to checking existing dependencies. The code for this is currently embedded in the registry index code and would need to be pulled out to be reused. We do not canonicalize git and path dependencies. It could be said that we should drop canonicalization completely to have parity between the code paths but it is less important for git / path dependencies because
|
The part I'm a little uncertain of is if we allow fuzzy lookups into the manifest file
|
#13702 is another manifestation of this |
I created a fix for this issue. I did not follow the route of doing fuzzy lookups within |
Fix cargo add behaving different when translating package name Fixes #13702 Fixes #10680 TODOs - [x] ~Fuzzy match registry dependencies in `cargo remove` as well~ `cargo remove` does not need fuzzy matching, because there is no unexpected behavior for the user - [x] ~Don't duplicate name permutation generation~ Unsure whether this is worth it - [ ] Shall we reject cases where multiple different permutations match? - [x] Add comments that explain the behavior
Fix cargo add behaving different when translating package name Fixes #13702 Fixes #10680 TODOs - [x] ~Fuzzy match registry dependencies in `cargo remove` as well~ `cargo remove` does not need fuzzy matching, because there is no unexpected behavior for the user - [x] ~Don't duplicate name permutation generation~ Unsure whether this is worth it - [ ] Shall we reject cases where multiple different permutations match? - [x] Add comments that explain the behavior
Problem
cargo add
can be used to add an optional feature to an existing dependency:Furthermore,
cargo add
can convert_
to-
and vice versa in crate names. However, when doing this translation, existing features are dropped:cargo add
should behave the same whether the crate name was written in its canonical form or not.Version
The text was updated successfully, but these errors were encountered: