Description
Rationale
This would allow us to support in-memory/patched (mainly for IDEs, maybe would be useful for build systems?) versions of source code when invoking rustc as a separate process.
While it's possible to provide a FileLoader
trait implementation when running rustc, it requires the user to run the compiler in-process.
Use cases
-
We would like to stop the RLS from depending on Clippy the library, which breaks often due to relying on rustc internals and thus is responsible for most of the RLS disappearances from nightly builds (Decouple nightly RLS from Clippy #59761).
I can't think of how we could solve this, short of ugly build-time hacks that would somehow detect if Clippy is compilable and if so, conditionally enable it via a feature (or provide a custom Clippy shim with IPC VFS support but that'd still include the lib and thus this comes back to the original stability problem).
EDIT: Done in Update RLS #61670. -
Due to the current RLS' architecture, we'd like to run the compiler as a separate process to compute the analysis in parallel - right now we compile all the primary crates in the workspace in a linear fashion in order to support easy VFS access to in-memory files and to reduce save-analysis serialization overhead.
This particular case could be side-stepped by implementing IPC for our VFS implementation that could be relayed to using our FileLoader trait and rustc shim (rls-rustc
).
Pros
- Uniform way to provide patched versions of the file at a process level
Cons
- This only helps dev tools use cases
- Has to be implemented and maintained
- We're not sure yet as to what the target architecture is for a rustc-as-a-language-server and in the long run this might not be necessary
I'd be interested in hearing your thoughts and whether we should ultimately support it.
cc'ing people that might be interested @nikomatsakis @matklad (anyone that I'm missing?)