Skip to content

Commit

Permalink
Fix inclusion/exclusion of optional dependencies (#2295)
Browse files Browse the repository at this point in the history
Follow-up to #2235 that corrects the `DependencyKind` used. This bug
caused optional dependencies to be incorrectly _included_ even no
feature activated that dependency. This can lead to crates being
compiled with missing features, resulting in compile errors.

For example, `sqlx==0.7.3` compiled successfully with `0.30.0`, but
fails with `0.31.0`:
```toml
sqlx = { version = "0.7.3", default-features = false, features = ["sqlite"] }
```
because `default-features = false` should remove the [optional
dependency](https://github.com/launchbadge/sqlx/blob/c55aba0dc14f33b8a26cab6af565fcc4c8af8962/Cargo.toml#L54-L56)
`sqlx-macros`. Instead, however, it gets incorrectly included but with
its crate dependencies' features missing, resulting in compile errors.

Related issue:
- #2262
  • Loading branch information
kersson authored Dec 1, 2023
1 parent ddf01c1 commit 0e39579
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crate_universe/src/metadata/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl DependencySet {
.partition(|dep| is_dev_dependency(dep));

(
collect_deps_selectable(node, dev, metadata, DependencyKind::Normal),
collect_deps_selectable(node, dev, metadata, DependencyKind::Development),
collect_deps_selectable(node, normal, metadata, DependencyKind::Normal),
)
};
Expand All @@ -66,7 +66,7 @@ impl DependencySet {

(
collect_deps_selectable(node, dev, metadata, DependencyKind::Development),
collect_deps_selectable(node, normal, metadata, DependencyKind::Development),
collect_deps_selectable(node, normal, metadata, DependencyKind::Normal),
)
};

Expand Down

0 comments on commit 0e39579

Please sign in to comment.