Skip to content

Commit df37576

Browse files
committed
Simplify bootstrap check-cfg arguments
1 parent d59f06f commit df37576

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/bootstrap/src/core/builder.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -1468,17 +1468,22 @@ impl<'a> Builder<'a> {
14681468
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
14691469
if *restricted_mode == None || *restricted_mode == Some(mode) {
14701470
// Creating a string of the values by concatenating each value:
1471-
// ',"tvos","watchos"' or '' (nothing) when there are no values
1472-
let values = match values {
1473-
Some(values) => values
1474-
.iter()
1475-
.map(|val| [",", "\"", val, "\""])
1476-
.flatten()
1477-
.collect::<String>(),
1478-
None => String::new(),
1471+
// ',values("tvos","watchos")' or '' (nothing) when there are no values.
1472+
let next = match values {
1473+
Some(values) => {
1474+
let mut tmp = values
1475+
.iter()
1476+
.map(|val| [",", "\"", val, "\""])
1477+
.flatten()
1478+
.collect::<String>();
1479+
1480+
tmp.insert_str(1, "values(");
1481+
tmp.push_str(")");
1482+
tmp
1483+
}
1484+
None => "".to_string(),
14791485
};
1480-
let values = values.strip_prefix(",").unwrap_or(&values); // remove the first `,`
1481-
rustflags.arg(&format!("--check-cfg=cfg({name},values({values}))"));
1486+
rustflags.arg(&format!("--check-cfg=cfg({name}{next})"));
14821487
}
14831488
}
14841489

0 commit comments

Comments
 (0)