about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorFolkert de Vries <folkert@folkertdev.nl>2025-07-14 11:03:16 +0200
committerFolkert de Vries <folkert@folkertdev.nl>2025-07-14 22:29:28 +0200
commitd0153f5872c484dff2a4b0ef6cad45c1f14fa1b7 (patch)
tree20c46ebb2dec80c1cc2cbae046639581d40a3116 /library
parent9c3064e131f4939cc95a29bb11413c49bbda1491 (diff)
downloadrust-d0153f5872c484dff2a4b0ef6cad45c1f14fa1b7.tar.gz
rust-d0153f5872c484dff2a4b0ef6cad45c1f14fa1b7.zip
update `cfg_select!` documentation
and make internal terminology consistent

Co-authored-by: Travis Cross <tc@traviscross.com>
Diffstat (limited to 'library')
-rw-r--r--library/core/src/macros/mod.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 6b9cbb06435..1b6dbc2f428 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -196,16 +196,14 @@ pub macro assert_matches {
     },
 }
 
-/// A macro for defining `#[cfg]` match-like statements.
+/// Selects code at compile-time based on `cfg` predicates.
 ///
-/// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of
-/// `#[cfg]` cases, emitting the implementation which matches first.
+/// This macro evaluates, at compile-time, a series of `cfg` predicates,
+/// selects the first that is true, and emits the code guarded by that
+/// predicate. The code guarded by other predicates is not emitted.
 ///
-/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
-/// without having to rewrite each clause multiple times.
-///
-/// Trailing `_` wildcard match arms are **optional** and they indicate a fallback branch when
-/// all previous declarations do not evaluate to true.
+/// An optional trailing `_` wildcard can be used to specify a fallback. If
+/// none of the predicates are true, a [`compile_error`] is emitted.
 ///
 /// # Example
 ///
@@ -225,7 +223,7 @@ pub macro assert_matches {
 /// }
 /// ```
 ///
-/// If desired, it is possible to return expressions through the use of surrounding braces:
+/// The `cfg_select!` macro can also be used in expression position:
 ///
 /// ```
 /// #![feature(cfg_select)]