mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Add -Z advanced-env
feature flag.
This commit is contained in:
parent
4d53519606
commit
154c787c72
@ -308,6 +308,7 @@ pub struct CliUnstable {
|
||||
pub avoid_dev_deps: bool,
|
||||
pub minimal_versions: bool,
|
||||
pub package_features: bool,
|
||||
pub advanced_env: bool,
|
||||
}
|
||||
|
||||
impl CliUnstable {
|
||||
@ -342,6 +343,7 @@ impl CliUnstable {
|
||||
"avoid-dev-deps" => self.avoid_dev_deps = true,
|
||||
"minimal-versions" => self.minimal_versions = true,
|
||||
"package-features" => self.package_features = true,
|
||||
"advanced-env" => self.advanced_env = true,
|
||||
_ => bail!("unknown `-Z` flag specified: {}", k),
|
||||
}
|
||||
|
||||
|
@ -965,7 +965,10 @@ impl<'de, 'config> de::Deserializer<'de> for Deserializer<'config> {
|
||||
visitor.visit_bool(v.parse().unwrap())
|
||||
} else if let Ok(v) = v.parse::<i64>() {
|
||||
visitor.visit_i64(v)
|
||||
} else if v.starts_with("[") && v.ends_with("]") {
|
||||
} else if self.config.cli_unstable().advanced_env
|
||||
&& v.starts_with("[")
|
||||
&& v.ends_with("]")
|
||||
{
|
||||
visitor.visit_seq(ConfigSeqAccess::new(self.config, self.key.clone())?)
|
||||
} else {
|
||||
visitor.visit_string(v.clone())
|
||||
@ -1121,6 +1124,7 @@ impl<'config> ConfigMapAccess<'config> {
|
||||
set.insert(ConfigKeyPart::CasePart(key));
|
||||
}
|
||||
}
|
||||
if config.cli_unstable().advanced_env {
|
||||
// CARGO_PROFILE_DEV_OVERRIDES_
|
||||
let env_pattern = format!("{}_", key.to_env());
|
||||
for env_key in config.env.keys() {
|
||||
@ -1133,6 +1137,7 @@ impl<'config> ConfigMapAccess<'config> {
|
||||
set.insert(ConfigKeyPart::CasePart(part.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(ConfigMapAccess {
|
||||
config,
|
||||
key,
|
||||
@ -1214,6 +1219,7 @@ impl ConfigSeqAccess {
|
||||
}
|
||||
}
|
||||
|
||||
if config.cli_unstable().advanced_env {
|
||||
// Parse an environment string as a TOML array.
|
||||
let env_key = key.to_env();
|
||||
let def = Definition::Environment(env_key.clone());
|
||||
@ -1247,6 +1253,7 @@ impl ConfigSeqAccess {
|
||||
res.push((s.to_string(), def.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(ConfigSeqAccess {
|
||||
list_iter: res.into_iter(),
|
||||
})
|
||||
|
@ -55,6 +55,15 @@ fn new_config(env: &[(&str, &str)]) -> Config {
|
||||
.collect();
|
||||
let mut config = Config::new(shell, cwd, homedir);
|
||||
config.set_env(env);
|
||||
config.configure(
|
||||
0,
|
||||
None,
|
||||
&None,
|
||||
false,
|
||||
false,
|
||||
&None,
|
||||
&["advanced-env".into()],
|
||||
).unwrap();
|
||||
config
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user