Rust analyser and cargo.toml refresh

I really enjoy using Rust-Analyser. It's faster than IntelliJ plugin and much more accurate.

However, I am struggling with updates after modifications to my project dependencies in Cargo.toml. They don't seem to be active in rust-analyser until I restart whole VSCode. Once I restart VSCode, deleted dependencies are no longer active and new dependencies are recognised as expected.
Is this expected behaviour or am I missing something basic?

For example:

  1. I've added random as a dependency
  2. Nothing relevant appears in auto-completion even after Cargo.toml and main.rs are saved
  3. Once I restart VSCode and wait for rust-analyser to settle, auto-completion works as expected

This is a long-standing limitation of rust-analyzer. I am looking into lifting it soonish though!

1 Like

Good to know. Would be great to document it, as both RLS and IntelliJ plugin automatically process changes to Cargo.toml.

Is there a way to gracefully reload just rust-analyser to deal with updated dependencies instead of restarting whole VSCode?

I haven't had this problem specifically but Ctrl+Shift+P -> Rust-Analyzer: Restart server usually works when I have some issue with rust-analyzer.

1 Like

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.