External Publication
Visit Post

Parser error recovery in `syn` for better IDE support with proc-macros

Rust Internals [Unofficial] May 31, 2026
Source

kpreid:

For attribute macros and derive macros, if the macro is getting called at all, you know that rustc thinks that the item is valid syntax and will not be producing an error. if you then get a syn parse error, then you must be in a case where syn doesn’t support the syntax rustc does, and in that case you had better tell the user that that’s the problem, because rustc won’t.

I'm not sure about rustc, but for rust-analyzer this is definitely not true.

Also, syntax not supported by syn is rare enough, and duplicate error, often unclear and in different place, is annoying enough, that I consider this acceptable.

Discussion in the ATmosphere

Loading comments...