Skip to content
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

Suggested test setup causes cargo warnings #352

Open
simonwuelker opened this issue May 8, 2024 · 2 comments
Open

Suggested test setup causes cargo warnings #352

simonwuelker opened this issue May 8, 2024 · 2 comments

Comments

@simonwuelker
Copy link

The suggested setup for tests using loom1 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 faern/oneshot#34)

Footnotes

  1. https://docs.rs/loom/latest/loom/#writing-tests

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

@Darksonn
Copy link
Contributor

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 tokio-rs/tokio#6538 for a more sophisticated setup.

@Urgau
Copy link

Urgau commented May 23, 2024

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)'] }

Footnotes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants