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

warning: unexpected cfg condition name: rustfmt #892

Open
asomers opened this issue May 5, 2024 · 2 comments
Open

warning: unexpected cfg condition name: rustfmt #892

asomers opened this issue May 5, 2024 · 2 comments

Comments

@asomers
Copy link

asomers commented May 5, 2024

The latest rustc compiler tries to detect the use of unknown #[cfg()] conditions. It's triggering in lalrpop-generated code. The easiest way to reproduce the problem is to simply run cargo check -p nobol in lalrpop's own git repo. Or, it can be reproduced by trying to compile a file like this:

grammar;

pub Num: i16 = r"[0-9]+" => i16::from_str(<>).unwrap();

Which results in the warning

warning: unexpected `cfg` condition name: `rustfmt`
  --> /usr/home/somers/src/rust/bfffs/target/debug/build/bfffs-555042f4e29eb538/out/x.rs:12:12
   |
12 | #[cfg_attr(rustfmt, rustfmt_skip)]
   |            ^^^^^^^
   |
   = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(rustfmt)");` 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

warning: unexpected `cfg` condition name: `rustfmt`
   --> /usr/home/somers/src/rust/bfffs/target/debug/build/bfffs-555042f4e29eb538/out/x.rs:303:12
    |
303 | #[cfg_attr(rustfmt, rustfmt_skip)]
    |            ^^^^^^^
    |
    = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(rustfmt)");` 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

This is the rust version I'm currently using:

> rustc --version -v
rustc 1.80.0-nightly (e82c861d7 2024-05-04)
binary: rustc
commit-hash: e82c861d7e5ecd766cb0dab0bf622445dec999dc
commit-date: 2024-05-04
host: x86_64-unknown-freebsd
release: 1.80.0-nightly
LLVM version: 18.1.4
@Pat-Lafon
Copy link
Contributor

This just landed on nightly right? I'm interested in fixing this(I think it exposed some other cfg issues that went undetected with cfg(feature = "test"). Ironically though, the example you included has just been fixed on the latest nightly(because of issues with rustfmt).

@asomers
Copy link
Author

asomers commented May 7, 2024

Yeah, it only started to fail sometime within the last few weeks.

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

2 participants