Parsing Rust code considered harmful
summary
Claim: naive parsing of Rust source fails for imports, macros and dependencies so multiple approaches are evaluated and one is chosen. Experiments use syn + cargo expand which is simple but lacks resolution, try embedding rustc as a library (callbacks, TyCtxt, MIR) which yields complete info but is brittle and high maintenance, and settle on rustdoc JSON -> cargo-breaking which extracts stable public-API data, is CI-friendly, and suggests a rust-analyzer plugin for near‑instant checks.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:50Static analysis in Rust
- 3:16cargo-breaking for breaking changes
- 7:10Challenges parsing Rust directly
- 12:27Why parsing Rust is harmful
- 13:10rustc as static analysis library
- 17:36rustc query engine limits
- 20:06Extracting crate data with rustdoc
- 23:37Comparing static analysis approaches
- 23:57Embedding analysis in Rust Analyzer
related talks
24mMacros for a More Productive Rust
29mMacromancy: an introduction to Rust macros
39mRust metaprogramming - macro_rules! beyond basics
25m"Eternal Sunshine of the Rustfmt'ed Mind"
19mCounterexamples in Safe Rust
11mEasy analysis of Rust code with Charon
32mBuilding and Maintaining Rust at Scale
29mRust is easy
