Parser error recovery in `syn` for better IDE support with proc-macros
Rust Internals [Unofficial]
May 31, 2026
programmerjake:
This isn't an issue of rustc only calling proc-macros with valid inputs, but of rust-analyzer calling a macro with input that doesn't parse because you haven't finished writing the input code and are trying to get code completions.
That’s fair. And in that case , I can see it being reasonable for the macro to fall back to passing through its input if it has nothing better can do, because rust-analyzer isn’t ever going to be 100% at reporting errors. But it is important that, when run by rustc, macros never just silently stop working.
So, I stand by my original suggestion: output a compile_error!() and the unmodified input. That should get you the completion benefits and also a guaranteed error.
Discussion in the ATmosphere