Skip to content

Commit

Permalink
Change the schedule to tomorrow (2024-05-05)
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed May 4, 2024
1 parent 80c2bb9 commit 2682b15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ team: The Cargo Team <https://www.rust-lang.org/governance/teams/dev-tools#cargo

# Automatic checking of cfgs at compile-time

The Cargo and Compiler team are delighted to announce that starting with Rust 1.80 (or nightly-2024-05-08) every _reachable_ `#[cfg]` will be automatically checked that they match the expected config names and values.
The Cargo and Compiler team are delighted to announce that starting with Rust 1.80 (or nightly-2024-05-05) every _reachable_ `#[cfg]` will be automatically checked that they match the expected config names and values.

This can help with verifying that the crate is correctly handling conditional compilation for different target platforms or features. It ensures that the cfg settings are consistent between what is intended and what is used, helping to catch potential bugs or errors early in the development process.

Expand Down Expand Up @@ -48,15 +48,15 @@ fn win() {}
```

*`cargo check`*:
![cargo-check](../../../../images/2024-05-08-check-cfg/cargo-check.svg)
![cargo-check](../../../../images/2024-05-05-check-cfg/cargo-check.svg)

## Custom cfgs and build scripts

> In Cargo point-of-view: a custom cfg is one that is neither defined by `rustc` nor by a Cargo feature. Think of `tokio_unstable`, `has_foo`, ... but not `feature = "lasers"`, `unix`, ...
Some crates use custom cfgs that they either expected from the environment (`RUSTFLAGS`or other means) or is enabled by some logic in the crate `build.rs`. For those crates Cargo provides a new instruction: [`cargo::rustc-check-cfg`](https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg)[^2] (or `cargo:rustc-check-cfg` for older Cargo version).

[^2]: `cargo::rustc-check-cfg` will start working in Rust 1.80 (or nightly-2024-05-08). From Rust 1.77 to Rust 1.79 *(inclusive)* it is silently ignored. In Rust 1.76 and below a warning is emitted when used without the unstable Cargo flag `-Zcheck-cfg`.
[^2]: `cargo::rustc-check-cfg` will start working in Rust 1.80 (or nightly-2024-05-05). From Rust 1.77 to Rust 1.79 *(inclusive)* it is silently ignored. In Rust 1.76 and below a warning is emitted when used without the unstable Cargo flag `-Zcheck-cfg`.

The syntax to use is described in the [rustc book](https://doc.rust-lang.org/nightly/rustc/) section [checking configuration](https://doc.rust-lang.org/nightly/rustc/check-cfg.html), but in a nutshell the basic syntax of `--check-cfg` is:

Expand Down

0 comments on commit 2682b15

Please sign in to comment.