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

error: unexpected cfg condition name: fuzzing #372

Open
larseggert opened this issue May 6, 2024 · 5 comments
Open

error: unexpected cfg condition name: fuzzing #372

larseggert opened this issue May 6, 2024 · 5 comments

Comments

@larseggert
Copy link

cargo 1.80.0-nightly (05364cb2f 2024-05-03) now throws the following clippy error:

error: unexpected `cfg` condition name: `fuzzing`
  --> neqo-transport/src/lib.rs:21:7
   |
21 | #[cfg(fuzzing)]
   |       ^^^^^^^
   |
   = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows`
   = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(fuzzing)");` 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
   = note: `-D unexpected-cfgs` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]`
@nagisa
Copy link
Member

nagisa commented May 6, 2024

This is when running clippy or is this reproducible with cargo check as well? Well, unfortunately, I don't think this is something we can fix on our side. Using and suggesting use of cfg(fuzzing) follows a well established example and it would be the tools that use the --check-cfg the way they do that are overzealous here (especially if they fail to provide mechanisms to modify the behaviour easily.)

I would report this issue against cargo (if the issue is reproducible with cargo check.)

@kpcyrd
Copy link

kpcyrd commented May 6, 2024

I assume this is related to this recent change: https://blog.rust-lang.org/2024/05/06/check-cfg.html

@larseggert
Copy link
Author

@kpcyrd Yes, it is. Sorry, I should have said so in the report.

@Urgau
Copy link

Urgau commented May 24, 2024

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

Cargo.toml:

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

I recommand directly suggesting it in the README.md, although the lint diagnostic should already suggest that.

Footnotes

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

@Shnatsel
Copy link
Member

Shnatsel commented Aug 6, 2024

fuzzing should probably become a well-known lint, given that all 3 major fuzzers automatically set it.

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

5 participants