-
Notifications
You must be signed in to change notification settings - Fork 13
Custom cfg loom makes cargo spam warnings #34
Description
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
rustcaware of thecfg. 2
Can be done by addingbuild.rsthat looks like thisfn 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)]tolib.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?