salsa-rs / salsa

A generic framework for on-demand, incrementalized computation. Inspired by adapton, glimmer, and rustc's query system.
https://salsa-rs.netlify.app/
Apache License 2.0
2.11k stars 146 forks source link

salsa::tracked proc-macro on fns/impls should handle invalid inputs #580

Open nikomatsakis opened 1 hour ago

nikomatsakis commented 1 hour ago

The #[salsa::tracked] macro, when applied to an impl or function, first attempts to just parse the entire thing with syn. It should handle malformed inputs by just echoing the existing tokens directly back to the user. Right now it doesn't do that and it causes rust-analyzer to not be able to work with incomplete code. I'm not sure if spitting back the tokens would be better but I bet it would.

nikomatsakis commented 1 hour ago

Mentoring instructions

This is the code that needs to be modified

https://github.com/salsa-rs/salsa/blob/a20b894cc2318c5a6077659e2d8aef7c784c38e7/components/salsa-macros/src/tracked.rs#L3-L7

that last line which invokes the macro should be altered to manually parse and recover from errors.