From 4bd72c7c375971af4411480bd4c08ee53a21dc5e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 19 Aug 2025 19:26:19 +0000 Subject: [PATCH] Revert "Remove `@__identity` rule." This change created a regression. This reverts commit 4d7a585e4d033280d3610c95aa0ea178444a3ff1. Closes: https://github.com/rust-lang/cfg-if/issues/90 --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 6bf5970..280af61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ macro_rules! cfg_if { $( $yes , )? not(any( $( $no ),* )) ))] - $( $tokens )* + $crate::cfg_if! { @__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 @@ -92,6 +92,12 @@ macro_rules! cfg_if { $( $rest , )* } }; + + // Internal macro to make __apply work out right for different match types, + // because of how macros match/expand stuff. + (@__identity $( $tokens:tt )* ) => { + $( $tokens )* + }; } #[cfg(test)]