nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
354 stars 83 forks source link

Fix logic for enabling features based on renamed dependencies #216

Closed duxovni closed 2 years ago

duxovni commented 2 years ago

When enableFeatures inspects optional dependencies to enable additional features in accordance with https://doc.rust-lang.org/nightly/cargo/reference/features.html#dependency-features , it can incorrectly enable features for the original names of renamed dependencies, and fail to enable features for the new names. For example, diesel has a feature "uuid" which adds uuid < 0.7.0 as a dependency, and a separate feature "uuidv07" which adds uuid >= 0.7.0 renamed as uuidv07. When the "uuidv07" feature is enabled, enableFeatures sees that one of the features enables the dependency uuid, so it also enables the "uuid" feature. However, the relevant dependency was renamed, and the non-renamed uuid < 0.7.0 required by the "uuid" feature isn't present among the dependencies, so the build breaks. This patch fixes enableFeatures and doesFeatureEnableDependency to correctly handle renamed dependencies.

Ericson2314 commented 2 years ago

Thanks for this!

Ericson2314 commented 2 years ago

I tested this by hand, thanks!