tokio-rs / loom

Concurrency permutation testing tool for Rust.
MIT License
2.08k stars 110 forks source link

Suggested test setup causes cargo warnings #352

Open Wuelle opened 4 months ago

Wuelle commented 4 months ago

The suggested setup for tests using loom^1 involves using a custom configuration. (#[cfg(loom)])

Unfortunately, this triggers the new rustc lint for unexpected cfg parameters ^2 (only available on the latest nightly version).

What is the suggested way to deal with this? Ideally one would not need to add a build.rs file just to register a custom cfg name.

(This issue stems from https://github.com/faern/oneshot/issues/34)

Darksonn commented 4 months ago

This is a new warning. For now the suggestion is to use a build script or add #![allow(unknown_lints, unexpected_cfgs)] at the top of your lib.rs file. Compare with https://github.com/tokio-rs/tokio/pull/6538 for a more sophisticated setup.

Urgau commented 3 months ago

Heads up, with the release of rust-lang/cargo#13913 (in nightly-2024-05-19), Cargo has now gain the ability to declare --check-cfg args directly inside the [lints] table with [lints.rust.unexpected_cfgs.check-cfg][^1]:

Cargo.toml:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] }

[^1]: take effect on Rust 1.80 (current nightly), is ignored on Rust 1.79 (current beta), and produce an unused warning below