The newest cargo nightly release includes automatic checking of expected cfg values. 1
The TLDR is that this is supposed to catch typos like #[cfg(windosw)].
Unfortunately, this lint triggers on oneshot's loom cfg quite a lot (24 times at the time of writing).
warning: unexpected `cfg` condition name: `loom`
--> src/lib.rs:125:11
|
125 | #[cfg(not(loom))]
| ^^^^
|
= help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(loom)");` to the top of the `build.rs`
= note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
Solutions
There are a few ways of fixing this:
-
Make rustc aware of the cfg. 2
Can be done by adding build.rs that looks like this
fn main() {
println!("cargo::rustc-check-cfg=cfg(loom)");
}
I am personally against this, since it would be adding a whole compilation step for basically nothing.
-
Add #![allow(unexpected_cfgs)] to lib.rs
Seems lazy?
-
Use a regular cargo feature instead.
Not great because cargo features are supposed to be additive 3. But seems possible.
-
Use #[cfg(test)] or some other standard-cfg instead of #[cfg(loom)]
Haven't looked at the actual tests enough to say whether this is reasonable at all
I would be happy to implement a fix for this, any thoughts on what would be a reasonable move?
The newest cargo nightly release includes automatic checking of expected
cfgvalues. 1The TLDR is that this is supposed to catch typos like
#[cfg(windosw)].Unfortunately, this lint triggers on oneshot's
loomcfg quite a lot (24 times at the time of writing).Solutions
There are a few ways of fixing this:
Make
rustcaware of thecfg. 2Can be done by adding
build.rsthat looks like thisI am personally against this, since it would be adding a whole compilation step for basically nothing.
Add
#![allow(unexpected_cfgs)]tolib.rsSeems lazy?
Use a regular cargo feature instead.
Not great because cargo features are supposed to be additive 3. But seems possible.
Use
#[cfg(test)]or some other standard-cfg instead of#[cfg(loom)]Haven't looked at the actual tests enough to say whether this is reasonable at all
I would be happy to implement a fix for this, any thoughts on what would be a reasonable move?
Footnotes
https://blog.rust-lang.org/2024/05/06/check-cfg.html ↩
https://doc.rust-lang.org/nightly/rustc/check-cfg.html ↩
https://doc.rust-lang.org/cargo/reference/features.html#feature-unification ↩