Commit Graph

322320 Commits

Author SHA1 Message Date
Chayim Refael Friedman 4e023db836 Merge pull request #21921 from Amit5601/fix-test-ignored-flag
fix: unconditionally pass --include-ignored for test runnables
2026-04-03 07:50:24 +00:00
Amit Singhmar ad5baa476d refactor: remove TestAttr and pass --include-ignored to test runnables 2026-04-03 07:26:47 +00:00
Chayim Refael Friedman 81bb240cf8 Merge pull request #21938 from A4-Tacks/indent-let-else-to-match
fix: Fix indent for convert_let_else_to_match
2026-04-03 06:50:56 +00:00
Chayim Refael Friedman b48416469a Merge pull request #21937 from A4-Tacks/wrap-paren-if-let-with-match
fix: wrap parentheses on guard for replace_if_let_with_match
2026-04-03 06:36:14 +00:00
A4-Tacks 84614569c9 fix: Fix indent for convert_let_else_to_match
Example
---
```rust
mod indent {
    fn foo() {
        let Ok(x) = f() else$0 {
            log();
            unreachable!(
                "..."
            );
        };
    }
}
```

**Before this PR**

```rust
mod indent {
    fn foo() {
        let x = match f() {
            Ok(x) => x,
            _ => {
                    log();
                    unreachable!(
                        "..."
                    );
                }
        };
    }
}
```

**After this PR**

```rust
mod indent {
    fn foo() {
        let x = match f() {
            Ok(x) => x,
            _ => {
                log();
                unreachable!(
                    "..."
                );
            }
        };
    }
}
```
2026-04-03 14:03:25 +08:00
A4-Tacks 4b42f62d14 fix: wrap parentheses on guard for replace_if_let_with_match
Example
---
```rust
fn main() {
    match$0 Some(0) {
        Some(n) if n % 2 == 0 || n == 7 => (),
        _ => (),
    }
}
```

**Before this PR**

```rust
fn main() {
    if let Some(n) = Some(0) && n % 2 == 0 || n == 7 {
        ()
    }
}
```

**After this PR**

```rust
fn main() {
    if let Some(n) = Some(0) && (n % 2 == 0 || n == 7) {
        ()
    }
}
```
2026-04-03 13:42:38 +08:00
Chayim Refael Friedman 440655df7e Merge pull request #21927 from A4-Tacks/no-expect-name-nested
fix: Not suggest name in nested type in variant
2026-04-03 02:33:55 +00:00
Shoyu Vanilla (Flint) 1676a45745 Merge pull request #21935 from ChayimFriedman2/array-elem-cfg
fix: Support cfg-ing array elements
2026-04-03 00:00:31 +00:00
Chayim Refael Friedman 2aefa3c8e9 Support cfg-ing array elements 2026-04-03 00:08:03 +03:00
Shoyu Vanilla (Flint) a21d450e1f Merge pull request #21933 from Wilfred/logging_in_slow_tests
internal: Ensure tracing is configured in slow tests
2026-04-02 17:44:30 +00:00
Wilfred Hughes 23fe3afc3e internal: Ensure tracing is configured in slow tests
rust-lang/rust-analyzer#16394 changed the logging initialisation to
create a Config struct, but never did anything with it. Call `.init()`
so slow tests have tracing configured.

You can test this by adding a test failure to a slow test,
e.g. `test_format_document_2018`, and then running it:

```
$ RA_LOG=trace RUN_SLOW_TESTS=1 cargo t test_format_document_2018
```

Previously this didn't log anything, even though RA_LOG was set.
2026-04-02 17:28:43 +01:00
Lukas Wirth 985ec34012 Merge pull request #21922 from Wilfred/proper_workspace_root
fix: Use the correct project root when there are multiple workspaces
2026-04-02 07:49:01 +00:00
A4-Tacks 5325fe3597 Merge pull request #21930 from Shourya742/2026-04-01-replace-add_trait_assoc_items_to_impl-with-factory-variant
Replace add trait assoc items to impl with its factory variant
2026-04-02 03:21:50 +00:00
bit-aloo 07643406f9 replace factory variant of add_trait_assoc_items_to_impl, as the main variant 2026-04-02 08:42:38 +05:30
bit-aloo 3dab2d34bd use factory variant of add_trait_assoc_items_to_impl in generate_impl 2026-04-01 22:16:31 +05:30
Laurențiu Nicola a34da5bc53 Merge pull request #21929 from Kobzol/ci-pr-author
Fix rustc-pull CI workflow
2026-04-01 12:05:17 +00:00
Jakub Beránek 99d0c35927 Fix rustc-pull CI workflow 2026-04-01 13:56:21 +02:00
Laurențiu Nicola 789fc4abfa Merge pull request #21923 from Wilfred/vscode_extension_kind
fix: Set VS Code extension kind explicitly
2026-04-01 07:23:56 +00:00
A4-Tacks 76d4fb28ae fix: Not suggest name in nested type in variant
Example
---
```rust
struct Other;
struct Vec<T>(T);
enum Foo {
    Vec(Vec<$0>)
}
```

**Before this PR**

```text
st Vec<…> Vec<{unknown}> [name]
en Foo Foo []
st Other Other []
sp Self Foo []
```

**After this PR**

```text
en Foo Foo []
st Other Other []
sp Self Foo []
st Vec<…> Vec<{unknown}> []
```
2026-04-01 14:51:25 +08:00
Shoyu Vanilla (Flint) 8f892ecf20 Merge pull request #21924 from erfanio/master
Update neovim LSP instructions for neovim 0.11+
2026-04-01 01:55:43 +00:00
Shoyu Vanilla (Flint) d3d3c5fcce Merge pull request #21915 from ChayimFriedman2/hang
fix: Fix a cycle in bounds lowering
2026-04-01 01:47:48 +00:00
Chayim Refael Friedman 4a58c0fe6b Merge pull request #21806 from Wilfred/dont_warn_on_cyclic_deps
internal: Document when crate cycles can occur
2026-04-01 01:44:31 +00:00
Chayim Refael Friedman d64a1b2bbd Merge pull request #21844 from Wilfred/watch_fuse_files
fix: Support filesystems that don't send Create events
2026-04-01 01:39:58 +00:00
erfanio f3dcff63f4 Update neovim LSP instructions for neovim 0.11+ 2026-04-01 08:28:40 +11:00
Wilfred Hughes 76e7fb9dd5 fix: Support filesystems that don't send Create events
On some filesystems, particularly FUSE on Linux, we don't get
Create(...) events. We do get Access(Open(Any)) events, so handle
those consistently with create/modify/remove events.

This fixes missed file notifications when using Sapling SCM with
EdenFS, although I believe the problem can occur on other FUSE
environments.

Reproduction:

Commit a change with Sapling that adds a new file foo.rs and
references it with `mod foo;` in lib.rs. Configure rust-analyzer as
follows:

```
{
    "rust-analyzer.files.watcher": "server",
    "rust-analyzer.server.extraEnv": {
        "RA_LOG": "vfs_notify=debug"
    },
}
```

Go to the previous commit, restart rust-analyzer, then go to the next
commit. The logs only show:

```
2026-03-18T07:16:54.211788903-07:00 DEBUG vfs-notify event event=NotifyEvent(Ok(Event { kind: Access(Open(Any)), paths: ["/data/users/wilfred/scratch/src/foo.rs"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }))
2026-03-18T07:16:54.211906733-07:00 DEBUG vfs-notify event event=NotifyEvent(Ok(Event { kind: Access(Open(Any)), paths: ["/data/users/wilfred/scratch/src/foo.rs"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }))
2026-03-18T07:16:54.216467168-07:00 DEBUG vfs-notify event event=NotifyEvent(Ok(Event { kind: Access(Open(Any)), paths: ["/data/users/wilfred/scratch/src/lib.rs"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }))
2026-03-18T07:16:54.216811304-07:00 DEBUG vfs-notify event event=NotifyEvent(Ok(Event { kind: Access(Open(Any)), paths: ["/data/users/wilfred/scratch/src/lib.rs"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }))
```

Observe that `mod foo;` has a red squiggle and shows "unresolved
module, can't find module file: foo.rs, or foo/mod.rs". This
commit fixes that.
2026-03-31 18:36:47 +01:00
Wilfred Hughes c9878352c8 internal: Split absolute path collection from reading files
This is not a logical change, and just makes the next commit simpler.

It also shouldn't impact performance, because the vast majority of
events have a single path.
2026-03-31 18:36:47 +01:00
Wilfred Hughes f28056fd00 fix: Use the correct project root when there are multiple workspaces
Previously, Config::root_path() would always return the LSP rootUri of
the first workspace folder. This can cause issues when the user has
multiple workspaces open in their editor, especially if the first one
in the list isn't a Rust project.

This was noted as an issue in rust-lang/rust-analyzer#21483, and added
comments suggesting that we should deprecate root_path().

This change splits root_path() into a `workspace_root_for()` function
that handles the multiple workspace case correctly, and a
`default_root_path()` fallback.

This is particularly useful when the user has configured
project-relative paths to e.g. their discover command or rustfmt, but
it's the correct behaviour in general.

AI disclosure: First draft was written with Claude Opus.
2026-03-31 18:35:18 +01:00
Wilfred Hughes 2dea90f91e fix: Set VS Code extension kind explicitly
The VS Code extension needs to be a `workspace` extension, because it
relies on access to the workspace. The rust-analyzer binary needs to
run on the same machine as the checkout of the code it's working on.

https://code.visualstudio.com/api/advanced-topics/remote-extensions#architecture-and-extension-kinds
https://code.visualstudio.com/api/advanced-topics/extension-host#preferred-extension-location

If an extension doesn't set extensionKind, VS Code will try to deduce
the kind based on the presence of various fields in the package.json,
such as a `main`.

https://github.com/microsoft/vscode/blob/fc23f2d26631c6a2c4bf9f69506ea74c90a32804/src/vs/workbench/services/extensions/common/extensionManifestPropertiesService.ts#L222

Instead, mark the extension kind as explicitly `workspace`. This is
more explicit and prevents future changes to package.json accidentally
making it run in the wrong environment. It's also helpful when
debugging startup bugs.
2026-03-31 18:29:24 +01:00
Wilfred Hughes 57ef70fb9a internal: Document when crate cycles can occur
This is legal when there are dev-dependencies, and rust-analyzer
itself even does this. This causes spurious warnings in several cases,
such as generating SCIP for rust-analyzer:

```
$ cargo run --bin rust-analyzer --release -- scip .
2026-03-12T18:40:33.824092Z  WARN cyclic deps: cfg(Idx::<CrateBuilder>(21)) -> cfg(Idx::<CrateBuilder>(21)), alternative path: cfg(Idx::<CrateBuilder>(21))
```

In this case, the `cfg` crate enables its `tt` feature by depending
on itself in dev-dependencies.
2026-03-31 14:28:18 +01:00
Laurențiu Nicola 96f289b6a6 Merge pull request #21516 from Master-Hash/fix-18578
Publish no-server to Code Marketplace and OpenVSX
2026-03-31 09:09:58 +00:00
Laurențiu Nicola 7018cfd605 Merge pull request #21916 from lnicola/bump-vsce-ovsx
minor: Bump @vscode/vsce and ovsx
2026-03-31 09:00:38 +00:00
Laurențiu Nicola 5e1b388bf8 Bump @vscode/vsce and ovsx 2026-03-31 11:51:22 +03:00
Chayim Refael Friedman 5d6e0dfc2b Merge pull request #21912 from A4-Tacks/conv-guarded-tail-expr-else
feat: offer on tail-expr with else-branch for if_let_to_guarded assist
2026-03-31 06:54:18 +00:00
Chayim Refael Friedman d10682bf45 Merge pull request #19659 from roife/fold-chained-expr
feat: add support for folding ranges for chained expressions
2026-03-31 05:24:38 +00:00
Chayim Refael Friedman 8f48f98d79 Merge pull request #20864 from A4-Tacks/extract-method-in-trait
Fix extract function invalid self param
2026-03-31 05:12:42 +00:00
A4-Tacks eec50b9748 Add a test for convert tail-expr to continue 2026-03-31 12:13:55 +08:00
Chayim Refael Friedman 422b7d2e2f Merge pull request #21892 from A4-Tacks/enum-variant-expect-name
feat: add expected name on simple enum variant
2026-03-31 03:31:38 +00:00
Chayim Refael Friedman 0640f1e260 Merge pull request #19956 from WaffleLapkin/more_qualified_paths
Implement `feature(more_qualified_paths)`
2026-03-31 02:40:31 +00:00
Waffle Lapkin d08892e642 implement feature(more_qualified_paths)
Specifically, this allows the following patterns and expressions which
were not allowed before:
```rust
let <T as Trait>::Assoc { a } = <T as Trait>::Assoc { a: 0 };

let (<E as Trait>::Assoc::ES { a } | <E as Trait>::Assoc::ET(a))
    = <E as Trait>::Assoc::ES { a: 0 };

let (<E>::ES { a } | <E>::ET(a)) = <E>::ES { a: 0 };
```

Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2026-03-31 05:30:55 +03:00
Chayim Refael Friedman 4e44f516d3 Merge pull request #21322 from asukaminato0721/4318
impl Display type hint inlay hints at the end of the line #4318
2026-03-31 01:19:44 +00:00
Chayim Refael Friedman 1c0f4cd801 Merge pull request #21695 from A4-Tacks/redundant-item-order
fix: Improve inserted order for trait_impl_redundant_assoc_item
2026-03-31 01:03:24 +00:00
Chayim Refael Friedman f8c9427819 Fix a cycle in bounds lowering
Those will never cease to surprise me.

Basically, an associated type bound can be either `Trait<Assoc: Trait>` or `Self::Assoc: Trait`. The former is included in `explicit_implied_predicates_of()` and therefore in elaboration, but the later is not. We included both, so fix that.

This does not fix the fundamental issue that cycles in elaboration can cause hangs/stack overflows, just this incorrect case. rustc deals with cycles by detecting them ahead of time (before any elaboration) and aborting with an error, I'm not sure yet how to handle them for r-a.

Also refactor the code a bit (the hundredth time) in an attempt to make it clearer, and return iterators instead of slices from the functions to be more flexible.
2026-03-31 00:54:19 +03:00
Chayim Refael Friedman a30ceb8306 Merge pull request #21903 from A4-Tacks/postfix-include-nots
fix: postfix completions include nots prefix-expr
2026-03-30 20:44:58 +00:00
Chayim Refael Friedman a17645a993 Merge pull request #21902 from A4-Tacks/nested-env-macro
fix: complete envs in nested `env!()`
2026-03-30 20:39:01 +00:00
Chayim Refael Friedman e291ef0c40 Merge pull request #21913 from Shourya742/2026-03-30-fix-doc-ci
Fix intra-doc link
2026-03-30 11:00:03 +00:00
bit-aloo 5e21b1715e fix doc link 2026-03-30 15:17:00 +05:30
A4-Tacks b56bca0ff6 Merge pull request #21886 from Shourya742/2026-03-26-migrate-gen-trait-fn-body
Replace make constructor with syntaxFactory in utils/gen trait fn body
2026-03-30 09:01:35 +00:00
bit-aloo e45ac4b1b7 accept make::ext:path_from_indents for Syntaxfactory constructor and add mapping for token tree from node constructor 2026-03-30 14:21:39 +05:30
A4-Tacks d29df23ea5 feat: offer with else-branch on tail-expr
For assist 'convert_to_guarded_return'

Example
---
```rust
fn main() -> i32 {
    if$0 true {
        foo();
    } else {
        bar()
    }
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
fn main() -> i32 {
    if false {
        return bar();
    }
    foo();
}
```
2026-03-30 16:05:19 +08:00
Laurențiu Nicola 183d948c84 Merge pull request #21881 from cuiweixie/fix/shim-libc-missing-args-messages
fix: Correct missing-args messages for sched_getaffinity and getenv shims
2026-03-30 07:07:29 +00:00