Rust: use all features by default

This commit is contained in:
Paolo Tranquilli
2025-05-21 15:15:03 +02:00
committed by Arthur Baars
parent 55be5fbf9e
commit ca661c7877
4 changed files with 47 additions and 14 deletions

View File

@@ -129,6 +129,23 @@ impl Config {
}
}
fn cargo_features(&self) -> CargoFeatures {
// '*' is to be considered deprecated but still kept in for backward compatibility
if self.cargo_features.is_empty() || self.cargo_features.iter().any(|f| f == "*") {
CargoFeatures::All
} else {
CargoFeatures::Selected {
features: self
.cargo_features
.iter()
.filter(|f| *f != "default")
.cloned()
.collect(),
no_default_features: !self.cargo_features.iter().any(|f| f == "default"),
}
}
}
pub fn to_cargo_config(&self, dir: &AbsPath) -> (CargoConfig, LoadCargoConfig) {
let sysroot = self.sysroot(dir);
(
@@ -159,16 +176,7 @@ impl Config {
.unwrap_or_else(|| self.scratch_dir.join("target")),
)
.ok(),
features: if self.cargo_features.is_empty() {
Default::default()
} else if self.cargo_features.contains(&"*".to_string()) {
CargoFeatures::All
} else {
CargoFeatures::Selected {
features: self.cargo_features.clone(),
no_default_features: false,
}
},
features: self.cargo_features(),
target: self.cargo_target.clone(),
cfg_overrides: to_cfg_overrides(&self.cargo_cfg_overrides),
wrap_rustc_in_build_scripts: false,