Skip to content

Commit 2e562c1

Browse files
committed
ra_project_model: Fix configuration of features
This commit fixes the handling of user-defined configuration of some cargo options. Previously you could either specify `--all-features`, `--no-default-features` or `--features`. Now you can specify either `--all-features` or `--no-default-features` and `--features`. This commit also corrects the `--features` command-line argument creation inside of `load_extern_resources`.
1 parent 8d9f8ac commit 2e562c1

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

crates/ra_project_model/src/cargo_workspace.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,15 @@ impl CargoWorkspace {
144144
meta.manifest_path(cargo_toml.to_path_buf());
145145
if cargo_features.all_features {
146146
meta.features(CargoOpt::AllFeatures);
147-
} else if cargo_features.no_default_features {
148-
// FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
149-
// https://github.com/oli-obk/cargo_metadata/issues/79
150-
meta.features(CargoOpt::NoDefaultFeatures);
151-
} else if !cargo_features.features.is_empty() {
152-
meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone()));
147+
} else {
148+
if cargo_features.no_default_features {
149+
// FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
150+
// https://github.com/oli-obk/cargo_metadata/issues/79
151+
meta.features(CargoOpt::NoDefaultFeatures);
152+
}
153+
if !cargo_features.features.is_empty() {
154+
meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone()));
155+
}
153156
}
154157
if let Some(parent) = cargo_toml.parent() {
155158
meta.current_dir(parent.to_path_buf());
@@ -289,12 +292,16 @@ pub fn load_extern_resources(
289292
cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml);
290293
if cargo_features.all_features {
291294
cmd.arg("--all-features");
292-
} else if cargo_features.no_default_features {
293-
// FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
294-
// https://github.com/oli-obk/cargo_metadata/issues/79
295-
cmd.arg("--no-default-features");
296295
} else {
297-
cmd.args(&cargo_features.features);
296+
if cargo_features.no_default_features {
297+
// FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
298+
// https://github.com/oli-obk/cargo_metadata/issues/79
299+
cmd.arg("--no-default-features");
300+
}
301+
if !cargo_features.features.is_empty() {
302+
cmd.arg("--features");
303+
cmd.arg(cargo_features.features.join(" "));
304+
}
298305
}
299306

300307
let output = cmd.output()?;

0 commit comments

Comments
 (0)