Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ declare_features! (
(accepted, cfg_target_abi, "1.78.0", Some(80970)),
/// Allows `cfg(target_feature = "...")`.
(accepted, cfg_target_feature, "1.27.0", Some(29717)),
/// Allows `cfg(target_has_atomic_primitive_alignment = "...")`.
(accepted, cfg_target_has_atomic_equal_alignment, "CURRENT_RUSTC_VERSION", Some(93822)),
/// Allows `cfg(target_vendor = "...")`.
(accepted, cfg_target_vendor, "1.33.0", Some(29718)),
/// Allows implementing `Clone` for closures where possible (RFC 2132).
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ const GATED_CFGS: &[GatedCfg] = &[
(sym::ub_checks, sym::cfg_ub_checks, Features::cfg_ub_checks),
(sym::contract_checks, sym::cfg_contract_checks, Features::cfg_contract_checks),
(sym::target_thread_local, sym::cfg_target_thread_local, Features::cfg_target_thread_local),
(
sym::target_has_atomic_equal_alignment,
sym::cfg_target_has_atomic_equal_alignment,
Features::cfg_target_has_atomic_equal_alignment,
),
(
sym::target_has_atomic_load_store,
sym::cfg_target_has_atomic,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ declare_features! (
(unstable, cfg_target_compact, "1.63.0", Some(96901)),
/// Allows `cfg(target_has_atomic_load_store = "...")`.
(unstable, cfg_target_has_atomic, "1.60.0", Some(94039)),
/// Allows `cfg(target_has_atomic_equal_alignment = "...")`.
(unstable, cfg_target_has_atomic_equal_alignment, "1.60.0", Some(93822)),
/// Allows `cfg(target_object_format = "...")`.
(unstable, cfg_target_object_format, "CURRENT_RUSTC_VERSION", Some(152586)),
/// Allows `cfg(target_thread_local)`.
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
| (sym::target_pointer_width, Some(_))
| (sym::target_vendor, None | Some(_))
| (sym::target_has_atomic, Some(_))
| (sym::target_has_atomic_equal_alignment, Some(_))
| (sym::target_has_atomic_primitive_alignment, Some(_))
| (sym::target_has_atomic_load_store, Some(_))
| (sym::target_has_reliable_f16, None | Some(_))
| (sym::target_has_reliable_f16_math, None | Some(_))
Expand Down Expand Up @@ -293,7 +293,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
ins_sym!(sym::target_has_atomic, sym);
}
if align.bits() == i {
ins_sym!(sym::target_has_atomic_equal_alignment, sym);
ins_sym!(sym::target_has_atomic_primitive_alignment, sym);
}
ins_sym!(sym::target_has_atomic_load_store, sym);
};
Expand Down Expand Up @@ -485,13 +485,10 @@ impl CheckCfg {
sym::integer(64usize),
sym::integer(128usize),
];
for sym in [
sym::target_has_atomic,
sym::target_has_atomic_equal_alignment,
sym::target_has_atomic_load_store,
] {
for sym in [sym::target_has_atomic, sym::target_has_atomic_load_store] {
ins!(sym, no_values).extend(atomic_values);
}
ins!(sym::target_has_atomic_primitive_alignment, empty_values).extend(atomic_values);

ins!(sym::target_thread_local, no_values);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,8 +2021,8 @@ symbols! {
target_feature_11,
target_feature_inline_always,
target_has_atomic,
target_has_atomic_equal_alignment,
target_has_atomic_load_store,
target_has_atomic_primitive_alignment,
target_has_reliable_f16,
target_has_reliable_f16_math,
target_has_reliable_f128,
Expand Down
11 changes: 5 additions & 6 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
target_has_atomic = "32",
target_has_atomic = "64",
target_has_atomic = "ptr",
target_has_atomic_equal_alignment = "8",
target_has_atomic_equal_alignment = "16",
target_has_atomic_equal_alignment = "32",
target_has_atomic_equal_alignment = "64",
target_has_atomic_equal_alignment = "ptr",
target_has_atomic_primitive_alignment = "8",
target_has_atomic_primitive_alignment = "16",
target_has_atomic_primitive_alignment = "32",
target_has_atomic_primitive_alignment = "64",
target_has_atomic_primitive_alignment = "ptr",
target_has_atomic_load_store = "8",
target_has_atomic_load_store = "16",
target_has_atomic_load_store = "32",
Expand Down Expand Up @@ -123,7 +123,6 @@
#![feature(auto_traits)]
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_has_atomic_equal_alignment)]
#![feature(cfg_ub_checks)]
#![feature(const_closures)]
#![feature(const_precise_live_drops)]
Expand Down
32 changes: 16 additions & 16 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ impl AtomicBool {
/// assert_eq!(some_bool, false);
/// ```
#[inline]
#[cfg(target_has_atomic_equal_alignment = "8")]
#[cfg(target_has_atomic_primitive_alignment = "8")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut bool) -> &mut Self {
// SAFETY: the mutable reference guarantees unique ownership, and
Expand Down Expand Up @@ -682,7 +682,7 @@ impl AtomicBool {
/// assert_eq!(some_bools, [true; 10]);
/// ```
#[inline]
#[cfg(target_has_atomic_equal_alignment = "8")]
#[cfg(target_has_atomic_primitive_alignment = "8")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut_slice(v: &mut [bool]) -> &mut [Self] {
// SAFETY: the mutable reference guarantees unique ownership, and
Expand Down Expand Up @@ -1593,7 +1593,7 @@ impl<T> AtomicPtr<T> {
/// assert_eq!(unsafe { *some_ptr }, 456);
/// ```
#[inline]
#[cfg(target_has_atomic_equal_alignment = "ptr")]
#[cfg(target_has_atomic_primitive_alignment = "ptr")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut *mut T) -> &mut Self {
let [] = [(); align_of::<AtomicPtr<()>>() - align_of::<*mut ()>()];
Expand Down Expand Up @@ -1672,7 +1672,7 @@ impl<T> AtomicPtr<T> {
/// }
/// ```
#[inline]
#[cfg(target_has_atomic_equal_alignment = "ptr")]
#[cfg(target_has_atomic_primitive_alignment = "ptr")]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut_slice(v: &mut [*mut T]) -> &mut [Self] {
// SAFETY:
Expand Down Expand Up @@ -3621,7 +3621,7 @@ macro_rules! atomic_int {
#[cfg(target_has_atomic_load_store = "8")]
atomic_int! {
cfg(target_has_atomic = "8"),
cfg(target_has_atomic_equal_alignment = "8"),
cfg(target_has_atomic_primitive_alignment = "8"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3639,7 +3639,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "8")]
atomic_int! {
cfg(target_has_atomic = "8"),
cfg(target_has_atomic_equal_alignment = "8"),
cfg(target_has_atomic_primitive_alignment = "8"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3657,7 +3657,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "16")]
atomic_int! {
cfg(target_has_atomic = "16"),
cfg(target_has_atomic_equal_alignment = "16"),
cfg(target_has_atomic_primitive_alignment = "16"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3675,7 +3675,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "16")]
atomic_int! {
cfg(target_has_atomic = "16"),
cfg(target_has_atomic_equal_alignment = "16"),
cfg(target_has_atomic_primitive_alignment = "16"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3693,7 +3693,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "32")]
atomic_int! {
cfg(target_has_atomic = "32"),
cfg(target_has_atomic_equal_alignment = "32"),
cfg(target_has_atomic_primitive_alignment = "32"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3711,7 +3711,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "32")]
atomic_int! {
cfg(target_has_atomic = "32"),
cfg(target_has_atomic_equal_alignment = "32"),
cfg(target_has_atomic_primitive_alignment = "32"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3729,7 +3729,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "64")]
atomic_int! {
cfg(target_has_atomic = "64"),
cfg(target_has_atomic_equal_alignment = "64"),
cfg(target_has_atomic_primitive_alignment = "64"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3747,7 +3747,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "64")]
atomic_int! {
cfg(target_has_atomic = "64"),
cfg(target_has_atomic_equal_alignment = "64"),
cfg(target_has_atomic_primitive_alignment = "64"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
stable(feature = "integer_atomics_stable", since = "1.34.0"),
Expand All @@ -3765,7 +3765,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "128")]
atomic_int! {
cfg(target_has_atomic = "128"),
cfg(target_has_atomic_equal_alignment = "128"),
cfg(target_has_atomic_primitive_alignment = "128"),
unstable(feature = "integer_atomics", issue = "99069"),
unstable(feature = "integer_atomics", issue = "99069"),
unstable(feature = "integer_atomics", issue = "99069"),
Expand All @@ -3783,7 +3783,7 @@ atomic_int! {
#[cfg(target_has_atomic_load_store = "128")]
atomic_int! {
cfg(target_has_atomic = "128"),
cfg(target_has_atomic_equal_alignment = "128"),
cfg(target_has_atomic_primitive_alignment = "128"),
unstable(feature = "integer_atomics", issue = "99069"),
unstable(feature = "integer_atomics", issue = "99069"),
unstable(feature = "integer_atomics", issue = "99069"),
Expand All @@ -3805,7 +3805,7 @@ macro_rules! atomic_int_ptr_sized {
#[cfg(target_pointer_width = $target_pointer_width)]
atomic_int! {
cfg(target_has_atomic = "ptr"),
cfg(target_has_atomic_equal_alignment = "ptr"),
cfg(target_has_atomic_primitive_alignment = "ptr"),
stable(feature = "rust1", since = "1.0.0"),
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
stable(feature = "atomic_debug", since = "1.3.0"),
Expand All @@ -3823,7 +3823,7 @@ macro_rules! atomic_int_ptr_sized {
#[cfg(target_pointer_width = $target_pointer_width)]
atomic_int! {
cfg(target_has_atomic = "ptr"),
cfg(target_has_atomic_equal_alignment = "ptr"),
cfg(target_has_atomic_primitive_alignment = "ptr"),
stable(feature = "rust1", since = "1.0.0"),
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
stable(feature = "atomic_debug", since = "1.3.0"),
Expand Down
6 changes: 4 additions & 2 deletions src/doc/rustc/src/check-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ the need to specify them manually.
Well known names and values are implicitly added as long as at least one `--check-cfg` argument
is present.

As of `2025-01-02T`, the list of known names is as follows:
As of `2026-05-15T`, the list of known names is as follows:

<!--- See CheckCfg::fill_well_known in compiler/rustc_session/src/config.rs -->

Expand All @@ -122,15 +122,17 @@ As of `2025-01-02T`, the list of known names is as follows:
- `target_endian`
- `target_env`
- `target_family`
- `target_object_format`
- `target_feature`
- `target_has_atomic`
- `target_has_atomic_equal_alignment`
- `target_has_atomic_primitive_alignment`
- `target_has_atomic_load_store`
- `target_os`
- `target_pointer_width`
- `target_thread_local`
- `target_vendor`
- `ub_checks`
- `contract_checks`
- `unix`
- `windows`

Expand Down
6 changes: 4 additions & 2 deletions tests/ui/cfg/disallowed-cli-cfgs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// ignore-tidy-linelength (target_has_atomic_primitive_alignment below overflows the linelength limit and @ [revision]compile-flags isn't detected by tidy as something to ignore)

//@ check-fail
//@ revisions: overflow_checks_ debug_assertions_ ub_checks_ sanitize_
//@ revisions: sanitizer_cfi_generalize_pointers_ sanitizer_cfi_normalize_integers_
//@ revisions: proc_macro_ panic_ target_feature_ unix_ windows_ target_abi_
//@ revisions: target_arch_ target_endian_ target_env_ target_family_ target_os_
//@ revisions: target_object_format_ target_pointer_width_ target_vendor_
//@ revisions: target_has_atomic_ target_has_atomic_equal_alignment_
//@ revisions: target_has_atomic_ target_has_atomic_primitive_alignment_
//@ revisions: target_has_atomic_load_store_ target_thread_local_ relocation_model_
//@ revisions: fmt_debug_
//@ revisions: emscripten_wasm_eh_
Expand All @@ -31,7 +33,7 @@
//@ [target_pointer_width_]compile-flags: --cfg target_pointer_width="32"
//@ [target_vendor_]compile-flags: --cfg target_vendor
//@ [target_has_atomic_]compile-flags: --cfg target_has_atomic="32"
//@ [target_has_atomic_equal_alignment_]compile-flags: --cfg target_has_atomic_equal_alignment="32"
//@ [target_has_atomic_primitive_alignment_]compile-flags: --cfg target_has_atomic_primitive_alignment="32"
//@ [target_has_atomic_load_store_]compile-flags: --cfg target_has_atomic_load_store="32"
//@ [target_thread_local_]compile-flags: --cfg target_thread_local
//@ [relocation_model_]compile-flags: --cfg relocation_model="a"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: unexpected `--cfg target_has_atomic_equal_alignment="32"` flag
error: unexpected `--cfg target_has_atomic_primitive_alignment="32"` flag
|
= note: config `target_has_atomic_equal_alignment` is only supposed to be controlled by `--target`
= note: config `target_has_atomic_primitive_alignment` is only supposed to be controlled by `--target`
= note: manually setting a built-in cfg can and does create incoherent behaviors
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: unexpected `--cfg target_has_atomic_primitive_alignment="32"` flag
|
= note: config `target_has_atomic_primitive_alignment` is only supposed to be controlled by `--target`
= note: manually setting a built-in cfg can and does create incoherent behaviors
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default

error: aborting due to 1 previous error

2 changes: 1 addition & 1 deletion tests/ui/check-cfg/well-known-names.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ LL | #[cfg(list_all_well_known_cfgs)]
`target_family`
`target_feature`
`target_has_atomic`
`target_has_atomic_equal_alignment`
`target_has_atomic_load_store`
`target_has_atomic_primitive_alignment`
`target_object_format`
`target_os`
`target_pointer_width`
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/check-cfg/well-known-values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#![feature(cfg_relocation_model)]
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_has_atomic_equal_alignment)]
#![feature(cfg_target_thread_local)]
#![feature(cfg_target_object_format)]
#![feature(cfg_ub_checks)]
Expand Down Expand Up @@ -65,10 +64,10 @@
// ^ tested in target_feature.rs
target_has_atomic = "_UNEXPECTED_VALUE",
//~^ WARN unexpected `cfg` condition value
target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE",
//~^ WARN unexpected `cfg` condition value
target_has_atomic_load_store = "_UNEXPECTED_VALUE",
//~^ WARN unexpected `cfg` condition value
target_has_atomic_primitive_alignment = "_UNEXPECTED_VALUE",
//~^ WARN unexpected `cfg` condition value
target_object_format = "_UNEXPECTED_VALUE",
//~^ WARN unexpected `cfg` condition value
target_os = "_UNEXPECTED_VALUE",
Expand Down
Loading
Loading