Auto merge of #143461 - folkertdev:cfg-select-builtin-macro, r=petrochenkov
make `cfg_select` a builtin macro tracking issue: https://github.com/rust-lang/rust/issues/115585 This parses mostly the same as the `macro cfg_select` version, except: 1. wrapping in double brackets is no longer supported (or needed): `cfg_select {{ /* ... */ }}` is now rejected. 2. in an expression context, the rhs is no longer wrapped in a block, so that this now works: ```rust fn main() { println!(cfg_select! { unix => { "foo" } _ => { "bar" } }); } ``` 3. a single wildcard rule is now supported: `cfg_select { _ => 1 }` now works I've also added an error if none of the rules evaluate to true, and warnings for any arms that follow the `_` wildcard rule. cc `@traviscross` if I'm missing any feature that should/should not be included r? `@petrochenkov` for the macro logic details
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
pub mod asm;
|
||||
pub mod attr;
|
||||
mod attr_wrapper;
|
||||
mod diagnostics;
|
||||
@@ -12,6 +11,11 @@ mod stmt;
|
||||
pub mod token_type;
|
||||
mod ty;
|
||||
|
||||
// Parsers for non-functionlike builtin macros are defined in rustc_parse so they can be used by
|
||||
// both rustc_builtin_macros and rustfmt.
|
||||
pub mod asm;
|
||||
pub mod cfg_select;
|
||||
|
||||
use std::assert_matches::debug_assert_matches;
|
||||
use std::{fmt, mem, slice};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user