External Publication
Visit Post

Why can't pat_param be followed by a colon in macro_rules?

Rust Internals [Unofficial] June 12, 2026
Source

I wrote this macro only to discover that pat_param fragments (otherwise known as PatternNoTopAlts cannot be followed by :s. As far as I can tell, PatternNoTopAlts cannot be terminated by a :. I get that there are potential forward compatibility concerns, but it is also my understanding that StructPatternFields make the prospect of adding type annotations to patterns quite awkward, and I figured that the ability to match something as integral as a let statement would be a higher priority.

Are there any other uses of : in patterns being considered?

Discussion in the ATmosphere

Loading comments...