rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.17k stars 12.27k forks source link

macro_rules! macros do not backtrack #42838

Open Mark-Simulacrum opened 7 years ago

Mark-Simulacrum commented 7 years ago

I'm mainly filing this to be able to close other issues whose problems come down to this. I don't know if we want to fix this or will fix this, but at least there will be a single issue for it.

iago-lito commented 5 years ago

Is it also a good place to gather resources explaining why it is the case that macros don't backtrack? I'm not particularly in need of bactracking, but I'm curious why this (no-)feature. I guess it's a limitation due to compiler optimization? Or maybe there are deeper theoretical problems with backtracking?

kmaork commented 3 years ago

Is there any progress here? Until this is solved, is there a recommended workaround for extracting the last element of a repetition? The best I've got is reversing the whole repetition using a recursive macro and then extracting the first element.