Skip to content

Commit

Permalink
Auto merge of #3410 - Urgau:new-check-cfg-syntax, r=JohnTitor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Oct 27, 2023
2 parents 0644a87 + 63e1ce2 commit 4e3317f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ jobs:
- name: Setup Rust toolchain
run: TOOLCHAIN=nightly sh ./ci/install-rust.sh
- name: Build with check-cfg
run: LIBC_CI=1 LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg=features,names,values,output
run: LIBC_CI=1 LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg

# These jobs doesn't actually test anything, but they're only used to tell
# bors the build completed, as there is no practical way to detect when a
Expand Down
12 changes: 10 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,19 @@ fn main() {
// https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg
if libc_check_cfg {
for cfg in ALLOWED_CFGS {
println!("cargo:rustc-check-cfg=values({})", cfg);
if rustc_minor_ver >= 75 {
println!("cargo:rustc-check-cfg=cfg({})", cfg);
} else {
println!("cargo:rustc-check-cfg=values({})", cfg);
}
}
for &(name, values) in CHECK_CFG_EXTRA {
let values = values.join("\",\"");
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
if rustc_minor_ver >= 75 {
println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values);
} else {
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
}
}
}
}
Expand Down

0 comments on commit 4e3317f

Please sign in to comment.