rust-analyzer subtree update#154572
Conversation
When rust-analyzer receives textDocument/didChangeWatchedFiles, we
want to trigger a flycheck in all workspaces if we can't find which
workspace owns those files.
However, since we used .any() instead of .all(), this behaviour was
always triggered when the user had more than one workspace.
Instead, use .all() so we correctly detect when the file it outside of
all workspaces.
---
For cargo-based projects, this just made rust-analyzer slower. For
projects with a custom check command using $saved_file or
{saved_file}, this introduced a race condition that sometimes
prevented diagnostics.
When we see the following flycheck events in this order:
// Created by textDocument/didSave.
RequestStateChange(Restart { ... saved_file: Some("foo.rs") })
// Created by textDocument/didChangeWatchedFiles
RequestStateChange(Restart { ... saved_file: None })
Then the flycheck debounce takes the last event, we invoke flycheck
with saved_file: None, and no flycheck occurs (because we require a
value to substitute in $saved_file).
Previously the debounce took the first event (until
rust-lang/rust-analyzer#21666), but that just meant a race condition
when events arrive in the opposite order.
Implement signature type inference
…ck_workspaces fix: Incorrect flychecks with multiple workspaces
Example
---
```rust
trait Foo {
}
impl Foo for () {
$0fn foo<T: Copy>(&self);
}
```
**Before this PR**:
```rust
trait Foo {
fn foo<T>(&self)
where
T: Copy,;
}
impl Foo for () {
fn foo<T: Copy>(&self);
}
```
**After this PR**:
```rust
trait Foo {
fn foo<T>(&self)
where
T: Copy,;
}
impl Foo for () {
fn foo<T: Copy>(&self);
}
```
…d-trait-assoc Fix indent for trait_impl_redundant_assoc_item
Example
---
```rust
fn main() {
let x = vec![1, 2, 3];
for$0 v in x {
let y = v * 2;
};
}
```
**Before this PR**
```rust
fn main() {
let x = vec![1, 2, 3];
let mut tmp = x.into_iter();
while let Some(v) = tmp.next() {
let y = v * 2;
};
}
```
**After this PR**
```rust
fn main() {
let x = vec![1, 2, 3];
let mut iter = x.into_iter();
while let Some(v) = iter.next() {
let y = v * 2;
};
}
```
…or-to-while-let Improve tmp iterator variable name for convert_for_to_while_let
…m-accept-expr Fix asm sym operand parsing for parenthesized expr fragments
…ract-util internal: extract default_fill_expr to utils
…ctory constructor
Example
---
```rust
enum X {
A,
B,
C,
}
use X::*;
fn main() {
match A {
$0A => todo!(),
B => todo!(),
C => todo!(),
}
}
```
**Before this PR**
Assist not applicable
**After this PR**
```rust
enum X {
A,
B,
C,
}
use X::*;
fn main() {
match A {
A | B => todo!(),
C => todo!(),
}
}
```
Example
---
```rust
fn test() {
let pat: bool = Some(true)$0?;
}
```
**Before this PR**
```rust
fn test() {
let Some(pat): bool = Some(true) else {
return None;
};
}
```
**After this PR**
```rust
fn test() {
let Some(pat): Option<bool> = Some(true) else {
return None;
};
}
```
…-wrap-ty fix: wrap `Option<>` for desugar_try_expr_let_else
when a local binding is used inside a macro call (e.g. write!(s, "{}", x.field)
or write!(s, "{}", t.0)), the usage's name node lives in the macro expansion
tree while the syntax editor is rooted at the source file tree. passing the
expansion node to editor.replace() causes apply_edits to panic when it resolves
the SyntaxNodePtr against the wrong tree.
instead of skipping macro-expanded usages, map them back to the original source
via sema.original_range_opt() and replace the text at the mapped range. this
follows the established pattern of upmapping macro code to source code rather
than ignoring it.
for destructure_struct_binding, macro field accesses like x.y are replaced with
the destructured field name y directly in the source. for
destructure_tuple_binding, a new TextReplace variant on EditTupleUsage handles
text-based replacements for macro-expanded tuple index accesses like x.0 → _0.
when original_range_opt cannot map back (e.g. the index originates from the
macro body rather than the call site), the code falls back to NoIndex (wrapping
in block comments) or skipping, matching previous behavior.
this also replaces the MacroStmts ancestor check in destructure_tuple_binding,
which only covered macros expanding to multiple statements and missed
single-expression macros (MacroExpr).
fixes rust-lang/rust-analyzer#20716
…truct-macro-panic fix: skip usages inside macro expansions in destructure struct/tuple binding
Example
---
```rust
enum E { A, B, C }
fn foo(t: E) -> i32 {
match $0t {
// variant a
E::A => 2
// comment on end
}
}
```
**Before this PR**
```rust
enum E { A, B, C }
fn foo(t: E) -> i32 {
match t {
E::A => 2,
E::B => ${1:todo!()},
E::C => ${2:todo!()},$0
}
}
```
**After this PR**
```rust
enum E { A, B, C }
fn foo(t: E) -> i32 {
match t {
// variant a
E::A => 2,
// comment on end
E::B => ${1:todo!()},
E::C => ${2:todo!()},$0
}
}
```
Fix not applicable on ambiguous ident pat for merge_match_arms
Hopefully it really works this time.
fix: Don't trigger GC on slow tests, take 2
minor: Replace `truncate(0)` with `clear()`
Fully implement `VariantFields `expression support
…yarn/editors/code/brace-expansion-1.1.13 Bump brace-expansion from 1.1.12 to 1.1.13 in /editors/code
Only allocate item blocks if they actually contain items or statement macros
Example
---
```rust
fn main() {
let y = match 0 {
0 |$0 => { 1i32 }
1 => { 2i32 }
};
}
```
**Before this PR**
Panic on apply
**After this PR**
Assist not applicable
fix: Fix block lowering in ast id map
…yarn/editors/code/multi-bf05dc1ecf Bump picomatch in /editors/code
…iling fix: don't panic unmerge arm on trailing pipe
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
|
|
|
@bors r+ p=1 |
This comment has been minimized.
This comment has been minimized.
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
|
Finished benchmarking commit (4cf5f95): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.1%, secondary -2.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 496.876s -> 485.768s (-2.24%) |
Subtree update of
rust-analyzerto rust-lang/rust-analyzer@f1297b2.Created using https://github.com/rust-lang/josh-sync.
r? @ghost