Nightly-only cfg gating like `#[cfg(target_has_atomic)]` is confusing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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_codewarning indicatingtarget_has_atomiccfg 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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two reported cases with rustc --crate-type="lib" and the bare #[cfg(target_has_atomic)] snippet on stable and nightly. Review the existing builtin-cfg and check-cfg tests, then establish what behavior is intended and add coverage for the bare form; done means the behavior is explicitly settled and tested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100