From 6061d81e74a17e024b59729024e126296de6b5af Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Thu, 23 Jul 2026 03:37:26 +0000
Subject: [PATCH 23/30] macro_rules: accept `const _` items in :item fragment
 matching

consume_item required an identifier after `const`, so an unnamed
constant (`const _: Ty = ...;`) failed fragment matching with "No arm
matched". Seen with os_str_bytes 6.4.1, which passes
`const _: &str = env!(...);` through a `$($item:item)+` macro.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wCVW89GjmNyYviEcANPHM
---
 src/macro_rules/eval.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp
index 60a59843..bdebda9e 100644
--- a/src/macro_rules/eval.cpp
+++ b/src/macro_rules/eval.cpp
@@ -1810,7 +1810,8 @@ namespace
             }
             else
             {
-                if( !lex.consume_if(TOK_IDENT) )
+                // `const _: Ty = ...;` (unnamed constant) is also valid
+                if( !lex.consume_if(TOK_IDENT) && !lex.consume_if(TOK_UNDERSCORE) )
                     return false;
                 if( !lex.consume_if(TOK_COLON) )
                     return false;
-- 
2.43.0

