rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.37k stars 1.62k forks source link

Redesign `rust-analyzer::flycheck` #18186

Open alibektas opened 2 months ago

alibektas commented 2 months ago

The current implementation of flycheck is flawed in that it instantiates at most a single "flycheck instance" for each workspace. With the introduction of rust-analyzer.toml files, more fine-grained configuration has become possible. Therefore, we need more flexibility in flycheck instances. At the same time, we want to avoid having many `flycheck' threads, as this is clearly inefficient.

Another issue that also needs to be addressed is how hard it is to test any kind of flycheck activity. The new model should make testing less of a problem for us.

Some key points about the new approach

Veykril commented 2 months ago

Dumping some quick notes/thoughts:

Current architecture:

Notably, this has the downside that we can only check a single package (or target even) per workspace. We also can bring down the system if there are a lot of workspaces and we check all of them at once.

Also, we do want to keep the property of having at most one flycheck worker run for a given workspace (multiple is non-sensical as they will block on another for the cargo lock anyways).

So maybe a job queue isn't actually needed and we can keep the per workspace workers, from the looks of it we mainly need to make them more flexible wrt. the command they invoke?