Skip to content

rust-analyzer subtree update#154572

Merged
rust-bors[bot] merged 93 commits intorust-lang:mainfrom
lnicola:sync-from-ra
Mar 30, 2026
Merged

rust-analyzer subtree update#154572
rust-bors[bot] merged 93 commits intorust-lang:mainfrom
lnicola:sync-from-ra

Conversation

@lnicola
Copy link
Copy Markdown
Member

@lnicola lnicola commented Mar 30, 2026

Subtree update of rust-analyzer to rust-lang/rust-analyzer@f1297b2.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost

Wilfred and others added 30 commits March 6, 2026 16:07
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.
…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
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
Veykril and others added 13 commits March 28, 2026 15:11
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
…yarn/editors/code/multi-bf05dc1ecf

Bump picomatch in /editors/code
…iling

fix: don't panic unmerge arm on trailing pipe
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 30, 2026

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Mar 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 30, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@lnicola
Copy link
Copy Markdown
Member Author

lnicola commented Mar 30, 2026

@bors r+ p=1

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Mar 30, 2026

📌 Commit 4095cfa has been approved by lnicola

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 30, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Mar 30, 2026

☀️ Test successful - CI
Approved by: lnicola
Duration: 3h 11m 59s
Pushing 4cf5f95 to main...

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

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)

@rust-bors rust-bors Bot merged commit 4cf5f95 into rust-lang:main Mar 30, 2026
12 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 30, 2026
@lnicola lnicola deleted the sync-from-ra branch March 30, 2026 11:16
@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4cf5f95): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.1%, 0.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.6%, -0.0%] 4
All ❌✅ (primary) - - 0

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.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.3%, -2.1%] 2
All ❌✅ (primary) 1.1% [1.1%, 1.1%] 1

Cycles

Results (secondary 1.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.2% [3.6%, 8.6%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-5.3%, -4.2%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 496.876s -> 485.768s (-2.24%)
Artifact size: 394.82 MiB -> 396.86 MiB (0.52%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.