-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Nightly-only cfg gating like #[cfg(target_has_atomic)]
is confusing
#133295
Comments
@Nemo157 has another example: For a given snippet and #[cfg(foo)] pub fn foo() -> usize { 1 }
#[cfg(foo = "bar")] pub fn bar() -> usize { 2 }
#[cfg(target_has_atomic)] pub fn target_has_atomic() -> usize { 3 }
#[cfg(target_has_atomic = "8")] pub fn target_has_atomic_8() -> usize { 4 } On stable 1.82.0 this codegens
On nightly 2024-11-20 this codegens
Further indicating that |
This cfg has been added in #106856, and means |
Oh... This is nightly-gated but it is not feature-gated |
cc @joshtriplett since you r+'d #106856 do you know if there a particular reason why |
All unstable cfg's are nigtly gated and not feature gated. |
Ah never mind, if that's intended behavior. |
That's not true, most unstable cfgs are both nightly gated and feature gated, rust/compiler/rustc_feature/src/builtin_attrs.rs Lines 17 to 40 in 717f5df
Btw, the current cfg feature gating system assumes that all the values are gated but that doesn't map well for |
I'm going to reopen this issue as a possible enhancement to make these kinds of gating less confusing... |
#[cfg(target_has_atomic)]
supposed to do?#[cfg(target_has_atomic)]
is confusing
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)dead_code
warning indicatingtarget_has_atomic
cfg is enabled.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?
The text was updated successfully, but these errors were encountered: