Skip to content

Commit 5e833bf

Browse files
committed
perf(build-rs): Always emit check-cfg
These didn't require an MSRV bump. Worse case, some metadata will be emitted but that shouldn't impact things too negatively.
1 parent 0f62101 commit 5e833bf

File tree

3 files changed

+13
-51
lines changed

3 files changed

+13
-51
lines changed

crates/build-rs/src/allow_use.rs

-30
This file was deleted.

crates/build-rs/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ MSRV: Respected as of "#,
4040
};
4141
}
4242

43-
mod allow_use;
4443
mod ident;
4544

4645
pub mod input;

crates/build-rs/src/output.rs

+13-20
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
//!
77
//! Reference: <https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script>
88
9-
use crate::{
10-
allow_use,
11-
ident::{is_ascii_ident, is_ident},
12-
};
9+
use crate::ident::{is_ascii_ident, is_ident};
1310
use std::{ffi::OsStr, fmt::Display, fmt::Write, path::Path, str};
1411

1512
fn emit(directive: &str, value: impl Display) {
@@ -309,13 +306,11 @@ pub fn rustc_check_cfgs(keys: &[&str]) {
309306
}
310307
}
311308

312-
if allow_use::check_cfg() {
313-
let mut directive = keys[0].to_string();
314-
for key in &keys[1..] {
315-
write!(directive, ", {key}").expect("writing to string should be infallible");
316-
}
317-
emit("rustc-check-cfg", format_args!("cfg({directive})"));
309+
let mut directive = keys[0].to_string();
310+
for key in &keys[1..] {
311+
write!(directive, ", {key}").expect("writing to string should be infallible");
318312
}
313+
emit("rustc-check-cfg", format_args!("cfg({directive})"));
319314
}
320315

321316
/// Add to the list of expected config names that is used when checking the
@@ -339,17 +334,15 @@ pub fn rustc_check_cfg_values(key: &str, values: &[&str]) {
339334
return;
340335
}
341336

342-
if allow_use::check_cfg() {
343-
let mut directive = format!("\"{}\"", values[0].escape_default());
344-
for value in &values[1..] {
345-
write!(directive, ", \"{}\"", value.escape_default())
346-
.expect("writing to string should be infallible");
347-
}
348-
emit(
349-
"rustc-check-cfg",
350-
format_args!("cfg({key}, values({directive}))"),
351-
);
337+
let mut directive = format!("\"{}\"", values[0].escape_default());
338+
for value in &values[1..] {
339+
write!(directive, ", \"{}\"", value.escape_default())
340+
.expect("writing to string should be infallible");
352341
}
342+
emit(
343+
"rustc-check-cfg",
344+
format_args!("cfg({key}, values({directive}))"),
345+
);
353346
}
354347

355348
/// The `rustc-env` instruction tells Cargo to set the given environment variable

0 commit comments

Comments
 (0)