Skip to content

Commit

Permalink
Do not use BTreeSet in Features::new
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Oct 22, 2023
1 parent 6a8723d commit cd6306b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Fix handling of optional dependency as features when namespaced features are not used together. This fixes a regression introduced in 0.6.11.

## [0.6.12] - 2023-10-18

- Fix compatibility with old Cargo. This fixes a regression introduced in 0.6.11.

## [0.6.11] - 2023-10-18

- Fix handling of weak dependency features when namespaced features is not used together.
- Fix handling of weak dependency features when namespaced features are not used together.

- Improve performance by passing `--no-deps` to `cargo metadata` except when using `--include-deps-features`.

Expand Down
9 changes: 6 additions & 3 deletions src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Features {
) -> Self {
let package = &metadata.packages[id];

let mut features: BTreeSet<_> = manifest.features.keys().map(Feature::from).collect();
let mut features: Vec<_> = manifest.features.keys().map(Feature::from).collect();
let mut has_namespaced_features = false; // features with `dep:` prefix

// package.features.values() does not provide a way to determine the `dep:` specified by the user.
Expand All @@ -40,7 +40,10 @@ impl Features {
// treated as implicit features.
if !has_namespaced_features {
for name in package.optional_deps() {
features.insert(name.into());
let feature = Feature::from(name);
if !features.contains(&feature) {
features.push(feature);
}
}
}
let deps_features_start = features.len();
Expand All @@ -64,7 +67,7 @@ impl Features {
}
}

Self { features: features.into_iter().collect(), optional_deps_start, deps_features_start }
Self { features, optional_deps_start, deps_features_start }
}

pub(crate) fn normal(&self) -> &[Feature] {
Expand Down

0 comments on commit cd6306b

Please sign in to comment.