about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2025-08-10 16:17:26 -0700
committerJosh Triplett <josh@joshtriplett.org>2025-08-10 16:18:01 -0700
commit38df15805ba5be78d70c515f1d585ee6be95e13b (patch)
tree9ab0eb80fa5284cc9bed785fa4e980a7090e8a54 /library
parent29737cb44beb67dbcf001ca1f11b7ec8964d8d06 (diff)
cfg_select: Support unbraced expressions
When operating on expressions, `cfg_select!` can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.
Diffstat (limited to 'library')
-rw-r--r--library/core/src/macros/mod.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index c59290a757b..db8b527d593 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -223,13 +223,14 @@ pub macro assert_matches {
 /// }
 /// ```
 ///
-/// The `cfg_select!` macro can also be used in expression position:
+/// The `cfg_select!` macro can also be used in expression position, with or without braces on the
+/// right-hand side:
 ///
 /// ```
 /// #![feature(cfg_select)]
 ///
 /// let _some_string = cfg_select! {
-///     unix => { "With great power comes great electricity bills" }
+///     unix => "With great power comes great electricity bills",
 ///     _ => { "Behind every successful diet is an unwatched pizza" }
 /// };
 /// ```