Nightly-only cfg gating like #[cfg(target_has_atomic)]
is confusing #133295
Open
Description
opened on Nov 21, 2024
EDIT: this is intended that cfg(target_has_atomic)
is nightly-only (not feature-gated), but I find it still very confusing.
Note that #[cfg(target_has_atomic)]
is not to be confused with #[cfg(target_has_atomic = "8")]
.
Given a snippet (just rustc --crate-type="lib"
, no additional --cfg
flags)
#[cfg(target_has_atomic)]
fn foo() {}
- On stable 1.82.0 this produces no warnings.
- On nightly 2024-11-20 this produces a
dead_code
warning indicatingtarget_has_atomic
cfg is enabled.
warning: function `foo` is never used
--> src/lib.rs:2:4
|
2 | fn foo() {}
| ^^^
|
= note: `#[warn(dead_code)]` on by default
AFAICT there is no test coverage for the intended behavior of just #[cfg(target_has_atomic)]
alone, other test coverage is mostly for check-cfg.
cc @Urgau since you worked on builtin-cfg rejection do you know anything about if this is intended, and if so, what is the intended behavior here?
Activity