Skip to content

Commit 999967a

Browse files
committed
Rename cfg_match! to cfg_select!
At [1] it was pointed out 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: rust-lang#115585 [1]: rust-lang#115585 (comment)
1 parent 444a627 commit 999967a

File tree

20 files changed

+60
-60
lines changed

20 files changed

+60
-60
lines changed

compiler/rustc_codegen_cranelift/patches/0027-sysroot_tests-128bit-atomic-operations.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ index 1e336bf..35e6f54 100644
1717
@@ -2,5 +2,4 @@
1818
// tidy-alphabetical-start
1919
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
20-
#![cfg_attr(test, feature(cfg_match))]
20+
#![cfg_attr(test, feature(cfg_select))]
2121
#![feature(alloc_layout_extra)]
2222
#![feature(array_chunks)]
2323
diff --git a/coretests/tests/atomic.rs b/coretests/tests/atomic.rs

compiler/rustc_data_structures/src/flock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! green/native threading. This is just a bare-bones enough solution for
55
//! librustdoc, it is not production quality at all.
66
7-
cfg_match! {
7+
cfg_select! {
88
target_os = "linux" => {
99
mod linux;
1010
use linux as imp;

compiler/rustc_data_structures/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#![feature(ascii_char_variants)]
2020
#![feature(assert_matches)]
2121
#![feature(auto_traits)]
22-
#![feature(cfg_match)]
22+
#![feature(cfg_select)]
2323
#![feature(core_intrinsics)]
2424
#![feature(dropck_eyepatch)]
2525
#![feature(extend_one)]

compiler/rustc_data_structures/src/profiling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ fn get_thread_id() -> u32 {
860860
}
861861

862862
// Memory reporting
863-
cfg_match! {
863+
cfg_select! {
864864
windows => {
865865
pub fn get_resident_set_size() -> Option<usize> {
866866
use windows::{

compiler/rustc_span/src/analyze_source_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) fn analyze_source_file(src: &str) -> (Vec<RelativeBytePos>, Vec<Multi
2929
(lines, multi_byte_chars)
3030
}
3131

32-
cfg_match! {
32+
cfg_select! {
3333
any(target_arch = "x86", target_arch = "x86_64") => {
3434
fn analyze_source_file_dispatch(
3535
src: &str,

compiler/rustc_span/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2121
#![doc(rust_logo)]
2222
#![feature(array_windows)]
23-
#![feature(cfg_match)]
23+
#![feature(cfg_select)]
2424
#![feature(core_io_borrowed_buf)]
2525
#![feature(hash_set_entry)]
2626
#![feature(if_let_guard)]

library/core/src/ffi/primitives.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type_alias! { "c_float.md", c_float = f32; }
3535
type_alias! { "c_double.md", c_double = f64; }
3636

3737
mod c_char_definition {
38-
crate::cfg_match! {
38+
crate::cfg_select! {
3939
// These are the targets on which c_char is unsigned. Usually the
4040
// signedness is the same for all target_os values on a given architecture
4141
// but there are some exceptions (see isSignedCharDefault() in clang).
@@ -133,7 +133,7 @@ mod c_char_definition {
133133
}
134134

135135
mod c_long_definition {
136-
crate::cfg_match! {
136+
crate::cfg_select! {
137137
any(
138138
all(target_pointer_width = "64", not(windows)),
139139
// wasm32 Linux ABI uses 64-bit long
@@ -172,7 +172,7 @@ pub type c_ptrdiff_t = isize;
172172
pub type c_ssize_t = isize;
173173

174174
mod c_int_definition {
175-
crate::cfg_match! {
175+
crate::cfg_select! {
176176
any(target_arch = "avr", target_arch = "msp430") => {
177177
pub(super) type c_int = i16;
178178
pub(super) type c_uint = u16;

library/core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
#![feature(bigint_helper_methods)]
101101
#![feature(bstr)]
102102
#![feature(bstr_internals)]
103-
#![feature(cfg_match)]
103+
#![feature(cfg_select)]
104104
#![feature(cfg_target_has_reliable_f16_f128)]
105105
#![feature(const_carrying_mul_add)]
106106
#![feature(const_eval_select)]
@@ -235,8 +235,8 @@ pub mod autodiff {
235235
#[unstable(feature = "contracts", issue = "128044")]
236236
pub mod contracts;
237237

238-
#[unstable(feature = "cfg_match", issue = "115585")]
239-
pub use crate::macros::cfg_match;
238+
#[unstable(feature = "cfg_select", issue = "115585")]
239+
pub use crate::macros::cfg_select;
240240

241241
#[macro_use]
242242
mod internal_macros;

library/core/src/macros/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ pub macro assert_matches {
210210
/// # Example
211211
///
212212
/// ```
213-
/// #![feature(cfg_match)]
213+
/// #![feature(cfg_select)]
214214
///
215-
/// cfg_match! {
215+
/// cfg_select! {
216216
/// unix => {
217217
/// fn foo() { /* unix specific functionality */ }
218218
/// }
@@ -228,19 +228,19 @@ pub macro assert_matches {
228228
/// If desired, it is possible to return expressions through the use of surrounding braces:
229229
///
230230
/// ```
231-
/// #![feature(cfg_match)]
231+
/// #![feature(cfg_select)]
232232
///
233-
/// let _some_string = cfg_match! {{
233+
/// let _some_string = cfg_select! {{
234234
/// unix => { "With great power comes great electricity bills" }
235235
/// _ => { "Behind every successful diet is an unwatched pizza" }
236236
/// }};
237237
/// ```
238-
#[unstable(feature = "cfg_match", issue = "115585")]
239-
#[rustc_diagnostic_item = "cfg_match"]
238+
#[unstable(feature = "cfg_select", issue = "115585")]
239+
#[rustc_diagnostic_item = "cfg_select"]
240240
#[rustc_macro_transparency = "semitransparent"]
241-
pub macro cfg_match {
241+
pub macro cfg_select {
242242
({ $($tt:tt)* }) => {{
243-
$crate::cfg_match! { $($tt)* }
243+
$crate::cfg_select! { $($tt)* }
244244
}},
245245
(_ => { $($output:tt)* }) => {
246246
$($output)*
@@ -250,10 +250,10 @@ pub macro cfg_match {
250250
$($( $rest:tt )+)?
251251
) => {
252252
#[cfg($cfg)]
253-
$crate::cfg_match! { _ => $output }
253+
$crate::cfg_select! { _ => $output }
254254
$(
255255
#[cfg(not($cfg))]
256-
$crate::cfg_match! { $($rest)+ }
256+
$crate::cfg_select! { $($rest)+ }
257257
)?
258258
},
259259
}

library/core/src/num/f32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use crate::convert::FloatToInt;
1515
use crate::num::{FpCategory, libm};
1616
use crate::panic::const_assert;
17-
use crate::{cfg_match, intrinsics, mem};
17+
use crate::{cfg_select, intrinsics, mem};
1818

1919
/// The radix or base of the internal representation of `f32`.
2020
/// Use [`f32::RADIX`] instead.
@@ -990,7 +990,7 @@ impl f32 {
990990
#[stable(feature = "num_midpoint", since = "1.85.0")]
991991
#[rustc_const_stable(feature = "num_midpoint", since = "1.85.0")]
992992
pub const fn midpoint(self, other: f32) -> f32 {
993-
cfg_match! {
993+
cfg_select! {
994994
// Allow faster implementation that have known good 64-bit float
995995
// implementations. Falling back to the branchy code on targets that don't
996996
// have 64-bit hardware floats or buggy implementations.

0 commit comments

Comments
 (0)