about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-22 02:14:23 +0000
committerbors <bors@rust-lang.org>2025-05-22 02:14:23 +0000
commit6eef33bb399cabfab16aa4e0825895f5f32f4e26 (patch)
treed5ad348ac4a4f699ed35aafc4327a09faaa62dd0 /library/core/src
parent5df0f729f5355cb3cd91f6bcff13566ae96dc220 (diff)
parent999967a57dce987bbad353d152f03c3ef67d41f2 (diff)
downloadrust-6eef33bb399cabfab16aa4e0825895f5f32f4e26.tar.gz
rust-6eef33bb399cabfab16aa4e0825895f5f32f4e26.zip
Auto merge of #137198 - tgross35:cfg-match-rename, r=Amanieu
Rename `cfg_match!` to `cfg_select!`

[`@Nemo157` pointed out](https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605) that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this.

Tracking issue: https://github.com/rust-lang/rust/issues/115585

[1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/ffi/primitives.rs6
-rw-r--r--library/core/src/lib.rs6
-rw-r--r--library/core/src/macros/mod.rs20
-rw-r--r--library/core/src/num/f32.rs4
-rw-r--r--library/core/src/slice/sort/select.rs4
-rw-r--r--library/core/src/slice/sort/stable/mod.rs6
-rw-r--r--library/core/src/slice/sort/unstable/mod.rs4
-rw-r--r--library/core/src/slice/sort/unstable/quicksort.rs4
8 files changed, 27 insertions, 27 deletions
diff --git a/library/core/src/ffi/primitives.rs b/library/core/src/ffi/primitives.rs
index 351bf9f8314..fa23cf33af4 100644
--- a/library/core/src/ffi/primitives.rs
+++ b/library/core/src/ffi/primitives.rs
@@ -35,7 +35,7 @@ type_alias! { "c_float.md", c_float = f32; }
 type_alias! { "c_double.md", c_double = f64; }
 
 mod c_char_definition {
-    crate::cfg_match! {
+    crate::cfg_select! {
         // These are the targets on which c_char is unsigned. Usually the
         // signedness is the same for all target_os values on a given architecture
         // but there are some exceptions (see isSignedCharDefault() in clang).
@@ -133,7 +133,7 @@ mod c_char_definition {
 }
 
 mod c_long_definition {
-    crate::cfg_match! {
+    crate::cfg_select! {
         any(
             all(target_pointer_width = "64", not(windows)),
             // wasm32 Linux ABI uses 64-bit long
@@ -172,7 +172,7 @@ pub type c_ptrdiff_t = isize;
 pub type c_ssize_t = isize;
 
 mod c_int_definition {
-    crate::cfg_match! {
+    crate::cfg_select! {
         any(target_arch = "avr", target_arch = "msp430") => {
             pub(super) type c_int = i16;
             pub(super) type c_uint = u16;
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index e605d7e0d78..b76213fdd41 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -100,7 +100,7 @@
 #![feature(bigint_helper_methods)]
 #![feature(bstr)]
 #![feature(bstr_internals)]
-#![feature(cfg_match)]
+#![feature(cfg_select)]
 #![feature(cfg_target_has_reliable_f16_f128)]
 #![feature(const_carrying_mul_add)]
 #![feature(const_eval_select)]
@@ -235,8 +235,8 @@ pub mod autodiff {
 #[unstable(feature = "contracts", issue = "128044")]
 pub mod contracts;
 
-#[unstable(feature = "cfg_match", issue = "115585")]
-pub use crate::macros::cfg_match;
+#[unstable(feature = "cfg_select", issue = "115585")]
+pub use crate::macros::cfg_select;
 
 #[macro_use]
 mod internal_macros;
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 7dc8c060cd5..4742add0957 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -210,9 +210,9 @@ pub macro assert_matches {
 /// # Example
 ///
 /// ```
-/// #![feature(cfg_match)]
+/// #![feature(cfg_select)]
 ///
-/// cfg_match! {
+/// cfg_select! {
 ///     unix => {
 ///         fn foo() { /* unix specific functionality */ }
 ///     }
@@ -228,19 +228,19 @@ pub macro assert_matches {
 /// If desired, it is possible to return expressions through the use of surrounding braces:
 ///
 /// ```
-/// #![feature(cfg_match)]
+/// #![feature(cfg_select)]
 ///
-/// let _some_string = cfg_match! {{
+/// let _some_string = cfg_select! {{
 ///     unix => { "With great power comes great electricity bills" }
 ///     _ => { "Behind every successful diet is an unwatched pizza" }
 /// }};
 /// ```
-#[unstable(feature = "cfg_match", issue = "115585")]
-#[rustc_diagnostic_item = "cfg_match"]
+#[unstable(feature = "cfg_select", issue = "115585")]
+#[rustc_diagnostic_item = "cfg_select"]
 #[rustc_macro_transparency = "semitransparent"]
-pub macro cfg_match {
+pub macro cfg_select {
     ({ $($tt:tt)* }) => {{
-        $crate::cfg_match! { $($tt)* }
+        $crate::cfg_select! { $($tt)* }
     }},
     (_ => { $($output:tt)* }) => {
         $($output)*
@@ -250,10 +250,10 @@ pub macro cfg_match {
         $($( $rest:tt )+)?
     ) => {
         #[cfg($cfg)]
-        $crate::cfg_match! { _ => $output }
+        $crate::cfg_select! { _ => $output }
         $(
             #[cfg(not($cfg))]
-            $crate::cfg_match! { $($rest)+ }
+            $crate::cfg_select! { $($rest)+ }
         )?
     },
 }
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index 43bf414d6be..bf67b6ed05a 100644
--- a/library/core/src/num/f32.rs
+++ b/library/core/src/num/f32.rs
@@ -14,7 +14,7 @@
 use crate::convert::FloatToInt;
 use crate::num::FpCategory;
 use crate::panic::const_assert;
-use crate::{cfg_match, intrinsics, mem};
+use crate::{cfg_select, intrinsics, mem};
 
 /// The radix or base of the internal representation of `f32`.
 /// Use [`f32::RADIX`] instead.
@@ -990,7 +990,7 @@ impl f32 {
     #[stable(feature = "num_midpoint", since = "1.85.0")]
     #[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
     pub const fn midpoint(self, other: f32) -> f32 {
-        cfg_match! {
+        cfg_select! {
             // Allow faster implementation that have known good 64-bit float
             // implementations. Falling back to the branchy code on targets that don't
             // have 64-bit hardware floats or buggy implementations.
diff --git a/library/core/src/slice/sort/select.rs b/library/core/src/slice/sort/select.rs
index c4808b1065d..82194db7fd8 100644
--- a/library/core/src/slice/sort/select.rs
+++ b/library/core/src/slice/sort/select.rs
@@ -6,7 +6,7 @@
 //! for pivot selection. Using this as a fallback ensures O(n) worst case running time with
 //! better performance than one would get using heapsort as fallback.
 
-use crate::cfg_match;
+use crate::cfg_select;
 use crate::mem::{self, SizedTypeProperties};
 #[cfg(not(feature = "optimize_for_size"))]
 use crate::slice::sort::shared::pivot::choose_pivot;
@@ -42,7 +42,7 @@ where
         let min_idx = min_index(v, &mut is_less).unwrap();
         v.swap(min_idx, index);
     } else {
-        cfg_match! {
+        cfg_select! {
             feature = "optimize_for_size" => {
                 median_of_medians(v, &mut is_less, index);
             }
diff --git a/library/core/src/slice/sort/stable/mod.rs b/library/core/src/slice/sort/stable/mod.rs
index a36e5f7801d..8b4e5c0c8c3 100644
--- a/library/core/src/slice/sort/stable/mod.rs
+++ b/library/core/src/slice/sort/stable/mod.rs
@@ -7,7 +7,7 @@ use crate::mem::{MaybeUninit, SizedTypeProperties};
 use crate::slice::sort::shared::smallsort::{
     SMALL_SORT_GENERAL_SCRATCH_LEN, StableSmallSortTypeImpl, insertion_sort_shift_left,
 };
-use crate::{cfg_match, intrinsics};
+use crate::{cfg_select, intrinsics};
 
 pub(crate) mod merge;
 
@@ -39,13 +39,13 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool, BufT: BufGuard<T>>(v: &mut [T], is_less
         return;
     }
 
-    cfg_match! {
+    cfg_select! {
         any(feature = "optimize_for_size", target_pointer_width = "16") => {
             // Unlike driftsort, mergesort only requires len / 2,
             // not len - len / 2.
             let alloc_len = len / 2;
 
-            cfg_match! {
+            cfg_select! {
                 target_pointer_width = "16" => {
                     let mut heap_buf = BufT::with_capacity(alloc_len);
                     let scratch = heap_buf.as_uninit_slice_mut();
diff --git a/library/core/src/slice/sort/unstable/mod.rs b/library/core/src/slice/sort/unstable/mod.rs
index b6c2e05a06a..d4df8d3a264 100644
--- a/library/core/src/slice/sort/unstable/mod.rs
+++ b/library/core/src/slice/sort/unstable/mod.rs
@@ -5,7 +5,7 @@ use crate::mem::SizedTypeProperties;
 use crate::slice::sort::shared::find_existing_run;
 #[cfg(not(any(feature = "optimize_for_size", target_pointer_width = "16")))]
 use crate::slice::sort::shared::smallsort::insertion_sort_shift_left;
-use crate::{cfg_match, intrinsics};
+use crate::{cfg_select, intrinsics};
 
 pub(crate) mod heapsort;
 pub(crate) mod quicksort;
@@ -30,7 +30,7 @@ pub fn sort<T, F: FnMut(&T, &T) -> bool>(v: &mut [T], is_less: &mut F) {
         return;
     }
 
-    cfg_match! {
+    cfg_select! {
         any(feature = "optimize_for_size", target_pointer_width = "16") => {
             heapsort::heapsort(v, is_less);
         }
diff --git a/library/core/src/slice/sort/unstable/quicksort.rs b/library/core/src/slice/sort/unstable/quicksort.rs
index 7e6cfb55990..98efee242eb 100644
--- a/library/core/src/slice/sort/unstable/quicksort.rs
+++ b/library/core/src/slice/sort/unstable/quicksort.rs
@@ -9,7 +9,7 @@ use crate::slice::sort::shared::pivot::choose_pivot;
 use crate::slice::sort::shared::smallsort::UnstableSmallSortTypeImpl;
 #[cfg(not(feature = "optimize_for_size"))]
 use crate::slice::sort::unstable::heapsort;
-use crate::{cfg_match, intrinsics, ptr};
+use crate::{cfg_select, intrinsics, ptr};
 
 /// Sorts `v` recursively.
 ///
@@ -142,7 +142,7 @@ const fn inst_partition<T, F: FnMut(&T, &T) -> bool>() -> fn(&mut [T], &T, &mut
     if size_of::<T>() <= MAX_BRANCHLESS_PARTITION_SIZE {
         // Specialize for types that are relatively cheap to copy, where branchless optimizations
         // have large leverage e.g. `u64` and `String`.
-        cfg_match! {
+        cfg_select! {
             feature = "optimize_for_size" => {
                 partition_lomuto_branchless_simple::<T, F>
             }