rust-lang / rust-lang/rust-analyzer
Build test-case minimization tool for rust-analyzer
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Sometimes we have problems like "rust-analyzer crashes on my 2k crates project" (1, 2).
The first step of debugging these issues involves minimization of example. Doing this manually is really tedious. However, most of minimization steps are semi-automated: replacing function bodies with loop {}, inlining modules, deleting irrelevant functions, inlining external crates...
We should build a tool which applies this transformations automatically!
Here are some design notes:
- http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/ is a spell book of transformations.
- the tool should be build on top of
ra_syntaxcrates. That is, it should be syntax driven, so that specifying transformations is natural, but it should not depend on semantic analysis of ra (otherwise, the tool itself will probably die on the problemantic code). The tool would probably need to understand simplemod foo;declarations, but that's it. - ideally, the tool should be automatic. Basically, if you can expose a crash with
cargo run --pacakge ra_cli -- analysis-stats PATH, you should be able to minimize it with justcargo run --pacakge ra_cli -- analysis-stats --minimize PATH. - the above blog post mentions a very cute hack of using local git repository as a way to record the sequence of minizations steps. The tool should use this hack.
cc @pnkfelix, I think that the work here might be useful for rustc as well? ra_syntax interface is relatively stable nowdays, so, regardless of what happens with rust-analyzer as a whole, maintaining this tool, after it is written, should not be a too big burden.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ra_syntax crates and the ra_cli analysis-stats command described in the issue; review the linked minimization patterns for candidate transformations. Done means an analysis-stats --minimize PATH workflow can automatically reduce a reproducing project, with local git history recording the minimization steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100