Rust Analyzer takes 20 minutes to scan

With my rather small testingt project, when depending on iced 0.12.0, iced_wiget 0.12.0, iced_runtime 0.12.0 und iced_aw 0.7.0 lokally installed, after starting VS code, the rust analyzer takes 20 miutes to scan the project. During that time, working is close to impossible.

It not only eats CPU and blocks the directories the user commands need, but it also miracolously causes that some 100 crates need to be recompiled when I do cargo check, run, …

On top of this, very often, the analyzer starts a long scanning session again when I just save main.rs.

How do you all deal with this ?

I personally deal with that using Vim.

But I would suggest the following:

  • Make sure your VSCode is up-to-date
  • Make sure your Rust Plugin for VSCode is up-to-date
  • Make sure your Rust tooling is up-to-date

Once you get all this done and the issue persists I believe you have two options:

  1. Look-up for possible new (or known) issue related to VSCode’s Rust Plugin and the rust-analyzer
  2. Look-up for documentation on how to adjust the VSCode’s Rust Plugin to be “less aggressive” a.k.a: not trigger periodically, not trigger when opening a window/project.

In resume. Seems to not be related to iced itself. Unless this scenario is happening ONLY with iced based projects I would recommend pursuing the answer on other forums. :slight_smile:

VS Code and Rust analyzer are the latest released versions.

Rustc is the current beta (Yesterday I read that the new nightly is supposed to be a lot faster. … downloading …)

IMHO It definitvely is a bug that rust analyzer in some way confuses the make process so that some crates get re-compiled when I do “cargo r” etc.

In fact it would be best if any crates could optionally could be handled as pure binaries. That would speed up the make process and prevent the analyzer from doing too much nonsense.

Does cargo privide such options ?

(Of course you are right: this very likely is not related to iced at all. But it might be of interest for other who use iced in their projects and hit the same problems. :smile: )

I switched to the newest nightly rustc 1.78.0-nightly (397937d81 2024-02-22) and indeed the ruist analyzer scanning process is a lot faster.

I am glad to hear you resolved your issues.

That sounds like an interesting question for https://users.rust-lang.org/

Keep grinding :saluting_face:

There already is:
Could Cargo install precompiled crates? - help - The Rust Programming Language Forum
Distributed crate cache · Issue #1997 · rust-lang/cargo · GitHub