Skip to content

Commit 1253bbf

Browse files
authored
fix(cli): correctly remove Cargo features (#7013)
1 parent 61e3ad8 commit 1253bbf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.changes/fix-feature-removal.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'cli.rs': 'patch'
3+
'cli.js': 'patch'
4+
---
5+
6+
Fixes Cargo.toml feature rewriting.

tooling/cli/src/interface/rust/manifest.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,15 @@ fn write_features(
146146
}
147147

148148
// remove features that shouldn't be in the manifest anymore
149-
let mut i = 0;
150-
while i < features_array.len() {
151-
if let Some(f) = features_array.get(i).and_then(|f| f.as_str()) {
149+
let mut i = features_array.len();
150+
while i != 0 {
151+
let index = i - 1;
152+
if let Some(f) = features_array.get(index).and_then(|f| f.as_str()) {
152153
if !features.contains(f) {
153-
features_array.remove(i);
154+
features_array.remove(index);
154155
}
155156
}
156-
i += 1;
157+
i -= 1;
157158
}
158159
} else {
159160
*manifest_features = Item::Value(Value::Array(toml_array(features)));

0 commit comments

Comments
 (0)