Skip to content

Commit 566a2c5

Browse files
committed
Fix CARGO_CFG_ vars for configs defined both with and without value
When a rustc cfg is defined both with and without value, the environment variable should provide all the values. Before this change, it ended up being empty. Fixes: #11789
1 parent c61b0f0 commit 566a2c5

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

src/cargo/core/compiler/custom_build.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,11 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
231231
for cfg in bcx.target_data.cfg(unit.kind) {
232232
match *cfg {
233233
Cfg::Name(ref n) => {
234-
cfg_map.insert(n.clone(), None);
234+
cfg_map.insert(n.clone(), Vec::new());
235235
}
236236
Cfg::KeyPair(ref k, ref v) => {
237-
if let Some(ref mut values) =
238-
*cfg_map.entry(k.clone()).or_insert_with(|| Some(Vec::new()))
239-
{
240-
values.push(v.clone())
241-
}
237+
let values = cfg_map.entry(k.clone()).or_insert_with(|| Vec::new());
238+
values.push(v.clone());
242239
}
243240
}
244241
}
@@ -249,14 +246,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
249246
continue;
250247
}
251248
let k = format!("CARGO_CFG_{}", super::envify(&k));
252-
match v {
253-
Some(list) => {
254-
cmd.env(&k, list.join(","));
255-
}
256-
None => {
257-
cmd.env(&k, "");
258-
}
259-
}
249+
cmd.env(&k, v.join(","));
260250
}
261251

262252
// Also inform the build script of the rustc compiler context.

0 commit comments

Comments
 (0)