A vision for refactoring the Rust compiler (rustc) into a set of independent, well-defined libraries with clean APIs — a concept called 'library-ification'. Combined with on-demand (query-based) analysis, this architecture would allow sharing components between rustc and rust-analyzer, make the compiler more accessible to contributors, and enable third-party analysis tools like Prusti or Clippy to directly leverage compiler internals (borrow checker results, MIR, type information) without resorting to hacks. The post also discusses stability and semver considerations for such public compiler APIs.
Table of contents
The problem statementIn theory, Rust is a great fit for analysisIn practice, analyzing Rust is a pain, but not because of the languageEnter: on-demand analysis and library-ificationThe first trend: On-demand analysisOn-demand analysis is a good fit for analysis toolsThe second trend: Library-ificationThe vision: shared componentsThe vision: Clean APIs defined in terms of Rust conceptsLibrary-ification can help make rustc more accessibleLibrary-ification will work best if APIs aren’t changingLibaries could be used by analysis tools as wellOn stability and semverConclusion6 Impressions