-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom cfg loom
makes cargo spam warnings
#34
Comments
Hmm.. None of the options seem ideal. I suggest bringing the question upstream, this pattern comes from loom itself and is nothing I invented here. Would be nice to have input from the loom developers and/or maybe have them update their recommendation and following that. |
I agree this is not nice! A build script should only be used when needed. I personally don't care as much about the compile time penalty. More the supply chain security aspect. A crate with a
Lazy indeed! I don't think this is an ideal solution. But it's what I'm doing temporary to get the CI working again (#36)
Indeed not additive. And I'm a fairly strong proponent for features being additive. Another downside is that cargo features are kind of "public features" of a crate. Loom is strictly for internal testing. This also mess with the
I don't think we are in "test mode" all the times when we want to use loom? 🤔 |
Unfortunately it seems like silencing the lint is the most sane option available at the moment :/ Its what was suggested on the loom issue i filed, and other projects are doing the same:
The only real "solution" that I've seen is adding a |
The blog post1 was updated, you can now modify [lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)', 'cfg(fuzzing)'] } I'll open a pr for this later Footnotes |
This solution seems waay cleaner! Looking forward to the PR ✨ |
The newest cargo nightly release includes automatic checking of expected
cfg
values. 1The 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).Solutions
There are a few ways of fixing this:
Make
rustc
aware of thecfg
. 2Can be done by adding
build.rs
that looks like thisI 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?
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 ↩
The text was updated successfully, but these errors were encountered: