From 335d22778114b1cdbe5da62f784d9bf76119cc82 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 19 May 2024 12:14:11 +0200 Subject: [PATCH 1/3] Enable strikethrough markdown extention in comrak --- src/posts.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/posts.rs b/src/posts.rs index b6bb7a6f4..bbfd6622d 100644 --- a/src/posts.rs +++ b/src/posts.rs @@ -73,6 +73,7 @@ impl Post { .build()?, extension: comrak::ExtensionOptionsBuilder::default() .header_ids(Some(String::new())) + .strikethrough(true) .footnotes(true) .table(true) .build()?, From 25793d639077123b73249705a448c4013f33b912 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 19 May 2024 12:15:11 +0200 Subject: [PATCH 2/3] Update check-cfg blog post with recent Cargo change --- posts/2024-05-06-check-cfg.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/posts/2024-05-06-check-cfg.md b/posts/2024-05-06-check-cfg.md index b1f4535eb..8024234da 100644 --- a/posts/2024-05-06-check-cfg.md +++ b/posts/2024-05-06-check-cfg.md @@ -52,6 +52,20 @@ fn win() {} ![cargo-check](../../../../images/2024-05-06-check-cfg/cargo-check.svg) +## Expecting static cfgs + +*UPDATE: This section was added with the release of nightly-2024-05-19.* + +Some crates might use cfgs, like `loom`, `fuzzing` which are always statically known at compile time. For those cases, Cargo provides via the `[lints]` table a way to statically declare those cfgs as expected. + +It is done through the special `check-cfg` config under `[lints.rust.unexpected_cfgs]`: + +*`Cargo.toml`* +```toml +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)', 'cfg(fuzzing)'] } +``` + ## 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` or `debug_assertions` @@ -115,9 +129,11 @@ This means that doing `RUSTFLAGS="--cfg tokio_unstable" cargo check` will not re ### How to expect custom cfgs without a `build.rs`? -There is **currently no way** to expect a custom cfg other than with `cargo::rustc-check-cfg` in a `build.rs`. +*UPDATE: Cargo with nightly-2024-05-19 now provides the `[lints.rust.unexpected_cfgs.check-cfg]` config to address the statically known custom cfgs.* + +~~There is **currently no way** to expect a custom cfg other than with `cargo::rustc-check-cfg` in a `build.rs`.~~ -Crate authors that don't want to use a `build.rs` are encouraged to use Cargo features instead. +Crate authors that don't want to use a `build.rs` and cannot use `[lints.rust.unexpected_cfgs.check-cfg]`, are encouraged to use Cargo features instead. ### How does it interact with other build systems? From 202d6bd87120f02554591404a42ce700f70c1c13 Mon Sep 17 00:00:00 2001 From: Urgau Date: Mon, 20 May 2024 17:26:03 +0200 Subject: [PATCH 3/3] Rework the flow of the check-cfg blog post with latest updates --- posts/2024-05-06-check-cfg.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/posts/2024-05-06-check-cfg.md b/posts/2024-05-06-check-cfg.md index 8024234da..24c4ef344 100644 --- a/posts/2024-05-06-check-cfg.md +++ b/posts/2024-05-06-check-cfg.md @@ -52,13 +52,15 @@ fn win() {} ![cargo-check](../../../../images/2024-05-06-check-cfg/cargo-check.svg) -## Expecting static cfgs +## Expecting custom cfgs *UPDATE: This section was added with the release of nightly-2024-05-19.* -Some crates might use cfgs, like `loom`, `fuzzing` which are always statically known at compile time. For those cases, Cargo provides via the `[lints]` table a way to statically declare those cfgs as expected. +> 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` or `debug_assertions` + +Some crates might use custom cfgs, like `loom`, `fuzzing` or `tokio_unstable` that they expected from the environment (`RUSTFLAGS` or other means) and which are always statically known at compile time. For those cases, Cargo provides via the `[lints]` table a way to statically declare those cfgs as expected. -It is done through the special `check-cfg` config under `[lints.rust.unexpected_cfgs]`: +Defining those custom cfgs as expected is done through the special `check-cfg` config under `[lints.rust.unexpected_cfgs]`: *`Cargo.toml`* ```toml @@ -66,11 +68,9 @@ It is done through the special `check-cfg` config under `[lints.rust.unexpected_ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)', 'cfg(fuzzing)'] } ``` -## 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` or `debug_assertions` +## Custom cfgs in build scripts -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). +On the other hand some crates use custom cfgs that are 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-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`.