File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -198,14 +198,11 @@ pub macro assert_matches {
198
198
199
199
/// A macro for defining `#[cfg]` match-like statements.
200
200
///
201
- /// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of
202
- /// `# [ cfg ] ` cases , emitting the implementation which matches first .
201
+ /// The `cfg_select!` macro checks a series of `#[cfg]` conditions, and picks the branch that
202
+ /// belongs to the first condition that evaluates to true .
203
203
///
204
- /// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code
205
- /// without having to rewrite each clause multiple times.
206
- ///
207
- /// Trailing `_` wildcard match arms are **optional** and they indicate a fallback branch when
208
- /// all previous declarations do not evaluate to true.
204
+ /// An optional trailing `_` wildcard match arm can be used to specify a fallback branch.
205
+ /// If none of the conditions evaluate to `true`, a compile error is emitted.
209
206
///
210
207
/// # Example
211
208
///
@@ -225,7 +222,7 @@ pub macro assert_matches {
225
222
/// }
226
223
/// ```
227
224
///
228
- /// If desired, it is possible to return expressions through the use of surrounding braces :
225
+ /// The `cfg_select!` macro can also be used in expression position :
229
226
///
230
227
/// ```
231
228
/// #![feature(cfg_select)]
Original file line number Diff line number Diff line change @@ -25,3 +25,6 @@ cfg_select! {
25
25
//~^ ERROR none of the rules in this `cfg_select` evaluated to true
26
26
false => { }
27
27
}
28
+
29
+ cfg_select ! { }
30
+ //~^ ERROR none of the rules in this `cfg_select` evaluated to true
Original file line number Diff line number Diff line change @@ -21,5 +21,11 @@ LL | | false => {}
21
21
LL | | }
22
22
| |_^
23
23
24
- error: aborting due to 2 previous errors; 1 warning emitted
24
+ error: none of the rules in this `cfg_select` evaluated to true
25
+ --> $DIR/cfg_select.rs:29:1
26
+ |
27
+ LL | cfg_select! {}
28
+ | ^^^^^^^^^^^^^^
29
+
30
+ error: aborting due to 3 previous errors; 1 warning emitted
25
31
You can’t perform that action at this time.
0 commit comments