Skip to content

Commit d9f2a08

Browse files
UrgauCleanCut
andauthored
Apply suggestions and update links to rustc book
Co-authored-by: Nathan Stocks <cleancut@github.com>
1 parent b02d576 commit d9f2a08

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

posts/2024-04-29-check-cfg.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This is another step to our commitment to provide user-focused tooling and we ar
1919

2020
## A look at the feature
2121

22-
Every time a Cargo feature is declared that feature is transformed into a config that is passed to `rustc` (the Rust compiler) so it can verify with its [well known cfgs](TODO) if any of the `#[cfg]`, `#![cfg_attr]` and `cfg!` have unexpected configs and report a warning with the `unexpected_cfgs` lint.
22+
Every time a Cargo feature is declared that feature is transformed into a config that is passed to `rustc` (the Rust compiler) so it can verify with its [well known cfgs](https://doc.rust-lang.org/nightly/rustc/check-cfg.html#well-known-names-and-values) if any of the `#[cfg]`, `#![cfg_attr]` and `cfg!` have unexpected configs and report a warning with the `unexpected_cfgs` lint.
2323

2424
*`Cargo.toml`*:
2525

@@ -56,9 +56,9 @@ fn win() {}
5656
5757
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`](TODO)[^2] (or `cargo:rustc-check-cfg` for older Cargo version).
5858

59-
[^2]: `cargo::rustc-check-cfg` will start working in Rust 1.80 (or nightly-2024-04-XX), between Rust 1.77 and Rust 1.79 *(included)* it silently did nothing and before that (so Rust 1.76 and below) it warned when used without the unstable Cargo `-Zcheck-cfg`.
59+
[^2]: `cargo::rustc-check-cfg` will start working in Rust 1.80 (or nightly-2024-04-XX). 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`.
6060

61-
The syntax to use is described in the [rustc book](https://doc.rust-lang.org/rustc/index.html) section [checking configuration](TODO), but in a nutshell the basic syntax of `--check-cfg` is:
61+
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:
6262

6363
> `cfg(name, values("value1", "value2", ..., "valueN"))`
6464
@@ -89,7 +89,7 @@ fn main() {
8989
| `foo="1"` and `bar="2"` | `cfg(foo, values("1"))` and `cfg(bar, values("2"))` |
9090
| `foo` and `foo="bar"` | `cfg(foo, values(none(), "bar"))` |
9191

92-
More details can be found on the [`rustc` book](TODO).
92+
More details can be found on the [`rustc` book](https://doc.rust-lang.org/nightly/rustc/check-cfg.html).
9393

9494
## Frequently asked questions
9595

@@ -108,8 +108,8 @@ This means that doing `RUSTFLAGS="--cfg tokio_unstable" cargo check` will not re
108108

109109
There is not **currently no way** to expect a custom cfg other than with `cargo::rustc-check-cfg` in a `build.rs`.
110110

111-
Crate author that don't want to use a `build.rs` are encouraged to use Cargo features instead.
111+
Crate authors that don't want to use a `build.rs` are encouraged to use Cargo features instead.
112112

113-
### Does it affect dependencies ?
113+
### Does the lint affect dependencies?
114114

115115
No, the lint only affects local packages; only those will report the lint.

0 commit comments

Comments
 (0)