From df375765b9df80bcde085d2fadaa0724687a3ca4 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 30 Dec 2023 15:13:04 +0100 Subject: Simplify bootstrap check-cfg arguments --- src/bootstrap/src/core/builder.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index e85753a3512..9bdcb75485b 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1468,17 +1468,22 @@ impl<'a> Builder<'a> { for (restricted_mode, name, values) in EXTRA_CHECK_CFGS { if *restricted_mode == None || *restricted_mode == Some(mode) { // Creating a string of the values by concatenating each value: - // ',"tvos","watchos"' or '' (nothing) when there are no values - let values = match values { - Some(values) => values - .iter() - .map(|val| [",", "\"", val, "\""]) - .flatten() - .collect::(), - None => String::new(), + // ',values("tvos","watchos")' or '' (nothing) when there are no values. + let next = match values { + Some(values) => { + let mut tmp = values + .iter() + .map(|val| [",", "\"", val, "\""]) + .flatten() + .collect::(); + + tmp.insert_str(1, "values("); + tmp.push_str(")"); + tmp + } + None => "".to_string(), }; - let values = values.strip_prefix(",").unwrap_or(&values); // remove the first `,` - rustflags.arg(&format!("--check-cfg=cfg({name},values({values}))")); + rustflags.arg(&format!("--check-cfg=cfg({name}{next})")); } } -- cgit 1.4.1-3-g733a5