Prioritise rustup sysroots over system ones
`get_path_for_executable` will now first check `$CARGO_HOME` before falling back to searching `$PATH`.
`rustup` is the recommended way to manage rust toolchains, therefore should be picked before the system toolchain.
Closes#16661
Document nvim 0.10 `inlay_hint`
It took me a few hours to figure out how to enable inlay type hints on Nvim 0.10 with `lspconfig`. `rustaceanvim` has already dropped support for them (https://github.com/mrcjkb/rustaceanvim/discussions/46#discussioncomment-7518669) and most other plugins, like `rust-tools`, are depreciated in favor of `rustaceanvim`.
This PR documents how to enable the inlay hints on Neovim 0.10 and later. I've tested this and changing the `on_attach` function is the only step that is required.
`get_path_for_executable` will now first check `$CARGO_HOME` before falling back to searching `$PATH`.
rustup is the recommended way to manage rust toolchains, therefore should be picked before the
system toolchain.
Add short flag -V for consistency with other rust tooling
Minor change to add the `-V` short flag to `rust-analyzer` to bring it in-line with other rust tooling such as:
> rustc -V
```bash
rustc 1.76.0 (07dca489a 2024-02-04)
```
> rustup -V
```bash
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.76.0 (07dca489a 2024-02-04)`
```
> cargo -V
```bash
cargo 1.76.0 (c84b36747 2024-01-18)
```
fix: Recompiles due to RUSTC_BOOTSTRAP
Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options. This causes flapping recompiles when building outside of RA.
Fixes#15057
internal: Optimize salsa memory usage
Reduces memory on self by ~20mb for me, there is a few more mb to save here if we made LRU caching opt-in, as currently every entry in a memoized query will store an `AtomicUsize` for the LRU.
fix: Fix proc-macro server not accounting for string delimiters correctly
Fixes https://github.com/rust-lang/rust-analyzer/issues/16622
Note that this is a bug a in the proc-macro server, so this won't be fixed until the next subtree sync
`cargo rustc -- <args>` first builds dependencies then calls `rustc <args>` for the current package. Here, we don't want to build dependencies, we just want to call `rustc --print`. An unstable `cargo rustc` `--print` command bypasses building dependencies first. This speeds up execution of this code path and ensures RA doesn't recompile dependencies with the `RUSTC_BOOTSRAP=1` env var flag set.
Note that we must pass `-Z unstable-options` twice, first to enable the `cargo` unstable `--print` flag, then later to enable the unstable `rustc` `target-spec-json` print request.
Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options it uses. This causes flapping recompiles when building outside of RA.
As of Cargo 1.75 the `--keep-going` flag is stable. This change uses the flag without `RUSTC_BOOTSTRAP` if the Cargo version is >= 1.75, and drops `--keep-going` otherwise. This fixes build script recompilation.