Enable `rust_analyzer` for cfgs when code is being analyzed by rust-analyzer
This allows one to have r-a skip analysis/replace macros that work not well with r-a at all by gating them behind this cfg (an example being the `quote` macro which r-a struggles with in terms of performance).
Do not send inlay hint refresh requests on file edits
See https://github.com/rust-lang/rust-analyzer/issues/13369#issuecomment-1695306870
Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints.
Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.
Bind unused parameter assistant
This PR introduces a new **Bind unused parameter assistant**.
While we do have a QuickFix from `rustc` (prefixing the parameter with an underscore), it's sometimes more convenient to suppress the warning using the following approach:
```rust
fn some_function(unused: i32) {}
```
->
```rust
fn some_function(unused: i32) {
let _ = unused;
}
```
code: remove `rust-analyzer.discoverProjectCommand` in favor of a companion extension
I think it's time to remove this functionality from the `rust-analyzer` and move it into a dedicated extension responsible for this. Selfishly, this changes makes it tenable to do progress reporting to the editor and potentially do some more complicated things around managing _which_ workspaces are being used.
minor : use crate name for `CARGO_CRATE_NAME`
fixes#15572 . Until now we used the package name as a replacement of crate name. With this PR r-a first sets all the env variables it set before and on top of those it tries to set `CARGO_CRATE_NAME` to crates name, following envvar's naming convention.
Replace format-args parser with upstream fork
Turns out we can't bump rustc_abi right now because it got its generics removed accidentally https://github.com/rust-lang/rust/pull/107163
On type format '(', by adding closing ')' automatically
If I understand right, `()` can surround pretty much the same `{}` can, so add another on type formatting pair for convenience: sometimes it's not that pleasant to write parenthesis in `Some(2).map(|i| (i, i+1))` cases and I would prefer r-a to do that for me.
One note: currently, b06503b6ec/crates/rust-analyzer/src/handlers/request.rs (L357) fires always.
Should we remove the assertion entirely now, since apparently things work in release despite that check?
Implement `write_via_move` intrinsic for mir-eval
Required for getting `write!`ing to work again. we fail with an odd type mimsatch eval error after this change though
internal: use current folder's `rustfmt.toml` with all rustfmt configurations
## Introduction
Resolves https://github.com/rust-lang/rust-analyzer/issues/15540. I moved the `chdir` functionality outside of the `match` to ensure that this functionality wouldn’t fall through again. As part of this PR, I also changed `from_proto::file_range` to accept a `TextDocumentIdentifier` by reference instead of by value, but I can undo this change if desired.
## Testing
I added a `rustfmt.toml` will the contents below at `crates/rust-analyzer/rustfmt.toml`:
```toml
reorder_modules = false
use_small_heuristics = "Max"
# this is the only difference from the `rustfmt.toml` at the root of the repo
tab_spaces = 8
```
In addition, I've also added `"rust-analyzer.rustfmt.overrideCommand": ["rustfmt"]` to my VS Code configuration.
With the above changes, saving `crates/rust-analyzer/src/handlers/request.rs` results in 8-space indentation. Meanwhile, saving `crates/toolchain/src/lib.rs` _does not_ result in any formatting changes.
Implement builtin#format_args, using rustc's format_args parser
`format_args!` now expands to `builtin#format_args(template, args...)`, the actual expansion now instead happens in lowering where we desugar this expression by using lang paths.
As a bonus, we no longer need to evaluate `format_args` as an eager macro which means less macro expansions overall -> less cache thrashing!
Fixes https://github.com/rust-lang/rust-analyzer/issues/15082
Bump `rustc-perf` checkout for metrics, replace webrender, diesel and ripgrep with newer versions
The previous versions were removed hence the updates. The metric results for the changed ones are disconnected now as to not muddle things up.
I think it's worth it for us to occasionally bump the `rustc-perf` checkout, as it allows us to include more interesting new targets.
Notably, the newer diesel is 3 times as fast to analyze as the one of the current checkout.