Changing the Project Specific Version of Rust

When I'm doing JavaScript work, I often have to switch between node/npm/yarn versions on a per project basis (I use Volta or nvm to do that).

In rust I can do something similar. For example, if I had a project using the 2024 edition of rust (1.85), I could install that version using rustup with rustup install 1.85, and then run rustup override set 1.85 in the project where I want to use that version. This won't change my system's default version of rust or the version of rust that other projects may be using.

So when I saw a rust analyzer error such as...

2025-03-09T12:10:25.5923969-06:00 ERROR FetchWorkspaceError: rust-analyzer failed to load workspace: Failed to load the project at C:\project\Cargo.toml: Failed to read Cargo metadata from Cargo.toml file C:\project\Cargo.toml, Some(Version { major: 1, minor: 80, patch: 0 }): Failed to run `"C:\\Users\\.cargo\\bin\\cargo.exe" "metadata" "--format-version" "1" "--manifest-path" "C:\\project\\Cargo.toml" "--filter-platform" "x86_64-pc-windows-msvc"`: `cargo metadata` exited with an error: error: failed to parse manifest at `C:\project\Cargo.toml`

Caused by:
  feature `edition2024` is required

  The package requires the Cargo feature called `edition2024`, but that feature is not stabilized in this version of Cargo (1.80.0 (376290515 2024-07-16)).
  Consider trying a newer version of Cargo (this may require the nightly release).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2024 for more information about the status of this feature.

That's saying that the package I was using required the "edition2024" feature but 1.80.0 (the version I was currently running) didn't support that feature. How do I know which version to use? Well, I could have looked at the rust-version field in Cargo.toml but that field is optional and wasn't there. The edition field was there however and it's required so I looked up the version associated with the rust edition by going here: 2024 goes with 1.85. So to fix it, I ran the rustup commands previously mentioned and then restarted Rust Analyzer.


Edit 7/29/2025:

A few additional notes about what I said above. As noted in the rust override --help command...

Overrides configure Rustup to use a specific toolchain when
running in a specific directory.

Directories can be assigned their own Rust toolchain with `rustup
override`. When a directory has an override then any time `rustc`
or `cargo` is run inside that directory, or one of its child
directories, the override toolchain will be invoked.

You can also view the override with rust override list and it will show you all the directories where you've set a custom version.

If you need to "undo" a custom version and go back to using the default toolchain, you can run rust override unset.