rust_analyzer takes forever to load; `cargo check` is instant.
from Doods@infosec.pub to rust@programming.dev on 04 Oct 07:44
https://infosec.pub/post/18414382

I was using Iced as a dependency, but wanted to tweak its source code for some reason, so I jumped into the folder where cargo downloads dependencies, and went into iced_wgpu 13.5 (I think that’s the version).

I could make a change, then run

cargo clean -p iced_wgpu && cargo check

in my other project for instant feedback, yet it took rust_analyzer at least 5 whole minutes to stop hallucinating.

Can I disable some functionality of rust_analyzer? I only use it for jump-to-definition, linting and syntax highlighting; I don’t even use autocomplete.

Setup:

TLDR

What can I disable in rust_analyzer to boost performance while maintaining jump-to-definition, linting and syntax-highlighting, or what can I do to boost rust_analyzer for big projects in general?

#rust

threaded - newest

Ciel@lemmygrad.ml on 04 Oct 08:09 next collapse

only thing that i can think off is that your ra install could be out of date? this sounds like some old ra bugs?

if its not tat, idk

nous@programming.dev on 04 Oct 08:58 next collapse

rust-analyzer I believe will compile all the deps the first time it runs. This will take some time but after that it should be fast. If you run a cargo clean that will wipe everything and you will have to wait again. So dont do that. clean should be something you run sparingly not before every compile.

TehPers@beehaw.org on 04 Oct 09:25 next collapse

Rather than modifying your dependencies in the cache directory (which is really not a good idea), consider cloning the repo directly. You can use a patch entry in your Cargo.toml to have all references to iced_wgpu point to your local modified copy.

5C5C5C@programming.dev on 04 Oct 16:34 collapse

OP really needs to heed this advice. Modifying things in the cache will cause breakages that will confuse the hell out of you.

BB_C@programming.dev on 04 Oct 11:18 next collapse

You don’t need to not use ra. Using ra-multiplex should improve your ra experience significantly.

With nvim, you can use vim.lsp.rpc.connect() in your setup.

soulsource@discuss.tchncs.de on 04 Oct 13:02 next collapse

No solution, but I have a similar issue with the higher crate.

There the /prelude/src/lib.rs file lets rust-analyzer lose its mind and allocate gigabytes upon gigabytes of memory, even though the file compiles just fine and nearly instantaneous…

I think this has something to do with recursive macros. Doesn’t iced also have such? I have faint memories of a column! macro?

calcopiritus@lemmy.world on 10 Oct 03:35 collapse

Not related to your question at all, but:

I don’t recommend editing the source code from cargo’s files. Instead, the correct way to modify a dependency would be making a fork and using it as a gift dependency (or path dependency, which is even easier).