Skip to content

Conversation

@JurajSadel
Copy link
Contributor

Gets rid of

error: unexpected `cfg` condition name: `test`

closes #4384

@JurajSadel JurajSadel added the skip-changelog No changelog modification needed label Oct 21, 2025
@bugadani
Copy link
Contributor

Do we know why exactly this warning is triggered? I remember debugging the same not too long ago, but I don't remember what came of it :/

@JurajSadel JurajSadel force-pushed the nightly-ci branch 4 times, most recently from bef6924 to 5aa44a9 Compare November 4, 2025 04:43
@MabezDev
Copy link
Member

MabezDev commented Nov 5, 2025

Hmm, I'm not sure this is the real fix. Isn't this likely related to the fact that when building no_std the compiler/cargo won't emit the check cfg(test)? cfg(test) usage also needs to be cfg_attr'd on no_std?

@JurajSadel
Copy link
Contributor Author

JurajSadel commented Nov 5, 2025

I spent some time analyzing this and here is the summary:

1.) This is on by default

rustc -W help

....
unexpected-cfgs  warn     detects unexpected names and values in `#[cfg]` conditions
....

2.) cargo build/check which is ran in cargo xtask ci --toolchain nightly doesn't know about test - I guess it's because of test is not part of known names?

Related from https://doc.rust-lang.org/rustc/check-cfg.html:

Starting with 1.85.0, the test cfg is considered to be a "userspace" config despite being also set by rustc and should be managed by the build system itself.

So, if I'm not missing something crucial here, I don't know how to deal with the errors besides what this PR does (adding println!("cargo::rustc-check-cfg=cfg(test)"); might be overkill since not all packages have build.rs)

EDIT: when it started to happen: rustc 1.92.0-nightly (f04e3dfc8 2025-10-19)
cc @bugadani @MabezDev

ignored = ["md-5", "esp-hal-procmacros"]

[lints.rust]
# Starting with 1.85.0, the test cfg is considered to be a "userspace" config despite being also set by rustc and should be managed by the build system itself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit wordy but probably fine

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this won't get any better the longer we wait - we should investigate this further and eventually come back to the unexpeced-cfg "workaround" but it won't harm to have it

Copy link
Contributor

@bugadani bugadani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand why this started happening now (the relevant changes were introduced in ~February), and why only on Linux - I can't reproduce any of the warnings (except for the actualy clippy lint) on Windows. Having this workaround makes me sad, and we should revisit in the future in case it can be removed.

@bugadani bugadani enabled auto-merge November 10, 2025 09:49
@bugadani bugadani added this pull request to the merge queue Nov 10, 2025
Merged via the queue into esp-rs:main with commit 8fd1239 Nov 10, 2025
29 checks passed
@JurajSadel JurajSadel deleted the nightly-ci branch November 10, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog No changelog modification needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly CI Failure

4 participants