Rust Analyzer Hanging Indefinitely

I'm working in a relatively large closed-source Rust workspace, and I've been having sporadic issues with RA (+ vscode) hanging forever locking up the CPU, but only in this workspace.

I normally use sccache to improve my incremental build times, but for the purposes of debugging, I've uninstalled it completely. I've also tried uninstalling RA, installing older versions, and deleting plugin files manually. I've tried deleting all rust build artifacts on my machine as well.

The other strange thing is I'm seeing similar behavior on a separate device, so I presume this is somehow related to this particular workspace, although no one else working in it is having this issue.

What else can I do to debug this issue?

I'd do the following:

  • run rust-analyzer analysis-stats /path/to/project. If that reproduces the hand, that would be much simpler to work from
  • try to minimize the example where the problem happens -- it probably is possible to minize this down to a single file
  • using a debugger, get a stack trace at the point where ra hangs

Thanks @matklad!

Another data point - I've been running without too much trouble, until I did a full reboot, and RA seemed to hang on opening the workspace in vscode. I waited, but eventually killed the process and disabled RA in vscode.

I tried running rust-analyzer analysis-stats /path/to/project but that also seemed to hang indefinitely. You said it should be much simpler to work from if I'm able to reproduce the hang as I have - what next steps do you recommend?

After restarting vscode, I ran cargo check/build/run without it taking too much time, and without errors. After this, I was able to run analysis-stats:

Database loaded:     15.69s (metadata 6.97s; build 6.99s)
  crates: 21, mods: 139, decls: 1428, fns: 856
Item Collection:     38.58s
  exprs: 62735, ??ty: 787 (1%), ?ty: 324 (0%), !ty: 17                  
Inference:           28.23s
Total:               66.81s

It seems like something is going on, only when I start up RA from a fresh boot, yet it's resolved by manually running cargo build.

Edit: It's also clear RA/rustc is doing something while it appears to hang: my computer is basically completely locked up with a rustc process hammering every logical processor.

I'll continue to debug and post here as I (hopefully) narrow this down.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.