diff options
| author | Josh Stone <jistone@redhat.com> | 2025-02-18 09:10:45 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-02-18 09:32:44 -0800 |
| commit | 3c45324e678d7148d542f08ced5c666dba2e1d60 (patch) | |
| tree | e5d08e737c8827d812fae27271435cf6f3a705fa /library/core/src/macros/mod.rs | |
| parent | 82ad08ea7fa613012b270789063544b7e9c53320 (diff) | |
| download | rust-3c45324e678d7148d542f08ced5c666dba2e1d60.tar.gz rust-3c45324e678d7148d542f08ced5c666dba2e1d60.zip | |
update `cfg(bootstrap)`
Diffstat (limited to 'library/core/src/macros/mod.rs')
| -rw-r--r-- | library/core/src/macros/mod.rs | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 4c6fd196bd3..16200184422 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -213,95 +213,6 @@ pub macro assert_matches { /// #![feature(cfg_match)] /// /// cfg_match! { -/// cfg(unix) => { -/// fn foo() { /* unix specific functionality */ } -/// } -/// cfg(target_pointer_width = "32") => { -/// fn foo() { /* non-unix, 32-bit functionality */ } -/// } -/// _ => { -/// fn foo() { /* fallback implementation */ } -/// } -/// } -/// ``` -#[cfg(bootstrap)] -#[unstable(feature = "cfg_match", issue = "115585")] -#[rustc_diagnostic_item = "cfg_match"] -pub macro cfg_match { - // with a final wildcard - ( - $(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+ - _ => { $($extra_tokens:tt)* } - ) => { - cfg_match! { - @__items (); - $((($initial_meta) ($($initial_tokens)*)),)+ - (() ($($extra_tokens)*)), - } - }, - - // without a final wildcard - ( - $(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })* - ) => { - cfg_match! { - @__items (); - $((($extra_meta) ($($extra_tokens)*)),)* - } - }, - - // Internal and recursive macro to emit all the items - // - // Collects all the previous cfgs in a list at the beginning, so they can be - // negated. After the semicolon is all the remaining items. - (@__items ($($_:meta,)*);) => {}, - ( - @__items ($($no:meta,)*); - (($($yes:meta)?) ($($tokens:tt)*)), - $($rest:tt,)* - ) => { - // Emit all items within one block, applying an appropriate #[cfg]. The - // #[cfg] will require all `$yes` matchers specified and must also negate - // all previous matchers. - #[cfg(all( - $($yes,)? - not(any($($no),*)) - ))] - cfg_match! { @__identity $($tokens)* } - - // Recurse to emit all other items in `$rest`, and when we do so add all - // our `$yes` matchers to the list of `$no` matchers as future emissions - // will have to negate everything we just matched as well. - cfg_match! { - @__items ($($no,)* $($yes,)?); - $($rest,)* - } - }, - - // Internal macro to make __apply work out right for different match types, - // because of how macros match/expand stuff. - (@__identity $($tokens:tt)*) => { - $($tokens)* - } -} - -/// A macro for defining `#[cfg]` match-like statements. -/// -/// 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 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. -/// -/// # Example -/// -/// ``` -/// #![feature(cfg_match)] -/// -/// cfg_match! { /// unix => { /// fn foo() { /* unix specific functionality */ } /// } @@ -324,7 +235,6 @@ pub macro cfg_match { /// _ => { "Behind every successful diet is an unwatched pizza" } /// }}; /// ``` -#[cfg(not(bootstrap))] #[unstable(feature = "cfg_match", issue = "115585")] #[rustc_diagnostic_item = "cfg_match"] pub macro cfg_match { @@ -1782,7 +1692,6 @@ pub(crate) mod builtin { /// The attribute carries an argument token-tree which is /// eventually parsed as a unary closure expression that is /// invoked on a reference to the return value. - #[cfg(not(bootstrap))] #[unstable(feature = "contracts", issue = "128044")] #[allow_internal_unstable(contracts_internals)] #[rustc_builtin_macro] @@ -1795,7 +1704,6 @@ pub(crate) mod builtin { /// The attribute carries an argument token-tree which is /// eventually parsed as an boolean expression with access to the /// function's formal parameters - #[cfg(not(bootstrap))] #[unstable(feature = "contracts", issue = "128044")] #[allow_internal_unstable(contracts_internals)] #[rustc_builtin_macro] |
