Expanded colons not allowed to match in macros?
⚓ Rust 📅 2026-01-16 👤 surdeus 👁️ 1macro_rules! spam {
(spam: { $($t:tt)* }) => { stringify!($($t)*) };
}
macro_rules! super_spam {
($x:ident) => { spam: { $x $x $x } };
}
fn main() {
// Doesn't work:
println!(spam! { super_spam!(spam) });
}
Trying to do something like in downcast-rs.
Edit: The expanded colon I said refers to the one in the definition of super_spam!
4 posts - 3 participants
🏷️ Rust_feed