Skip to content

Custom cfg loom makes cargo spam warnings #34

Description

@simonwuelker

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?

Footnotes

  1. https://blog.rust-lang.org/2024/05/06/check-cfg.html ↩

  2. https://doc.rust-lang.org/nightly/rustc/check-cfg.html ↩

  3. https://doc.rust-lang.org/cargo/reference/features.html#feature-unification ↩

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions