Parser error recovery in `syn` for better IDE support with proc-macros
Currently when using an attribute proc-macro on some function it is basically impossible to recover from parse errors from syn in a reasonable fashion for IDE support, any syntax error causes parsing to fail entirely meaning the proc-macro's entire output is generally just compile_error! or it panics. It would be very nice to support doing the proc-macro's transformation on the non-erroneous parts of the input so you can still get reasonable code completion and type hints and other IDE niceties even if the input is incomplete or broken.
e.g. if you have a proc-macro like #[async_trait]:
#[async_trait]
pub trait MyTrait {
async fn my_fn(&self) {
let = self. // currently typing here
}
}
syn can't parse that as a trait with a let that's missing a variable and the initializer is missing a method, so it makes IDE completion much worse. (this could be a relatively mild case since completion on the macro inputs ignoring the proc-macro mostly gives the same results (icr if rust-analyzer does that), other macros do more transformation so completion ignoring the proc-macro give bad results or just nothing at all (which is my experience)).
Discussion in the ATmosphere