Skip to content

Commit 4e3317f

Browse files
committed
Auto merge of #3410 - Urgau:new-check-cfg-syntax, r=JohnTitor
Use new check-cfg syntax in newer nightly [MCP636 - Simplify and improve explicitness of the check-cfg syntax](rust-lang/compiler-team#636) introduced a new syntax for check-cfg. This PR adjust the `build.rs` code to use the new syntax on `rustc >= 75`. The old syntax is still used on older version since on rust-lang/rust we need to be compatible with both for now.
2 parents 0644a87 + 63e1ce2 commit 4e3317f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/workflows/bors.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ jobs:
333333
- name: Setup Rust toolchain
334334
run: TOOLCHAIN=nightly sh ./ci/install-rust.sh
335335
- name: Build with check-cfg
336-
run: LIBC_CI=1 LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg=features,names,values,output
336+
run: LIBC_CI=1 LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg
337337

338338
# These jobs doesn't actually test anything, but they're only used to tell
339339
# bors the build completed, as there is no practical way to detect when a

build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,19 @@ fn main() {
167167
// https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg
168168
if libc_check_cfg {
169169
for cfg in ALLOWED_CFGS {
170-
println!("cargo:rustc-check-cfg=values({})", cfg);
170+
if rustc_minor_ver >= 75 {
171+
println!("cargo:rustc-check-cfg=cfg({})", cfg);
172+
} else {
173+
println!("cargo:rustc-check-cfg=values({})", cfg);
174+
}
171175
}
172176
for &(name, values) in CHECK_CFG_EXTRA {
173177
let values = values.join("\",\"");
174-
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
178+
if rustc_minor_ver >= 75 {
179+
println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values);
180+
} else {
181+
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
182+
}
175183
}
176184
}
177185
}

0 commit comments

Comments
 (0)