23756 Commits

Author SHA1 Message Date
Lukas Wirth
9d58a93602
Merge pull request #20439 from A4-Tacks/t-macro-bracket-doc
Add guess braces doc `T![]` for `T_`
2025-12-21 14:19:06 +00:00
Lukas Wirth
14cc41f2ba
Merge pull request #20438 from A4-Tacks/fix-guess-renamed-macro-braces
Fix guess renamed macro braces
2025-12-21 14:18:55 +00:00
Lukas Wirth
47037adcac
Merge pull request #20577 from A4-Tacks/nested-if-indent
Fix indent for merge_nested_if
2025-12-21 14:03:50 +00:00
Lukas Wirth
ee9783825a
Merge pull request #20576 from A4-Tacks/nested-if-let
Fix nested if-let for merge_nested_if
2025-12-21 14:03:26 +00:00
Lukas Wirth
5b9198d11f
Merge pull request #20597 from A4-Tacks/conv-to-guarded-ret-doc
Add LetStmt doc for convert_to_guarded_return
2025-12-21 14:02:06 +00:00
Lukas Wirth
3aecf081f6
Merge pull request #20996 from A4-Tacks/explicit-dot-call-deref
Add ide-assist: add_explicit_method_call_deref
2025-12-21 13:50:43 +00:00
Lukas Wirth
82d4f8bacd
Merge pull request #21304 from asukaminato0721/19168
internal: Improve recursive mbe parsing behavior
2025-12-21 12:39:05 +00:00
Chayim Refael Friedman
ccb2ffe653
Merge pull request #21311 from A4-Tacks/serde-derive-feature
internal: Fix hir-ty implicit serde derive feature
2025-12-21 07:42:18 +00:00
A4-Tacks
5abec3c2ce
internal: Fix hir-ty implicit serde derive feature
bad commit: 0dd3fe029a532c6c5fa3b0bdd7c4eb57843bb156
cwd: crates/hir-ty
cmd: cargo check
output: error: cannot find derive macro `Serialize` in this scope
2025-12-21 15:30:47 +08:00
Chayim Refael Friedman
8f28e82a4f
Merge pull request #21212 from A4-Tacks/comp-try-let-default-varname
Add default varname for TryEnum postfix completion
2025-12-21 06:13:23 +00:00
A4-Tacks
847317ccba
Add default varname for TryEnum postfix completion
Example
---
```rust
fn main() {
    let bar = Some(true);
    bar.i$0
}
```

**Before this PR**

```rust
fn main() {
    let bar = Some(true);
    if let Some($1) = bar {
        $0
    }
}
```

**After this PR**

```rust
fn main() {
    let bar = Some(true);
    if let Some(${1:bar}) = bar {
        $0
    }
}
```
2025-12-21 13:55:21 +08:00
Chayim Refael Friedman
961fd33e8e
Merge pull request #21310 from ChayimFriedman2/remove-attach-db
minor: Remove some redundant `attach_db()`s
2025-12-21 05:53:58 +00:00
Chayim Refael Friedman
b5fbcc6917
Merge pull request #21166 from A4-Tacks/fly-closure-this-param
Support undotted-self for `this` param closure
2025-12-21 05:37:24 +00:00
Chayim Refael Friedman
65c14db957 Remove some redundant attach_db()s 2025-12-21 07:10:19 +02:00
Chayim Refael Friedman
cbc18ae50c
Merge pull request #21289 from A4-Tacks/add-ref-matched-type
Complete reference `&T` -> `&&T`
2025-12-21 05:08:04 +00:00
Chayim Refael Friedman
3d25bbf964
Merge pull request #21291 from A4-Tacks/expected-nested-match-arm-expr-ty
Fix match arm nested body invalid expected type
2025-12-21 05:04:56 +00:00
A4-Tacks
f8f69b2a61
Complete reference &T -> &&T
Example
---
```rust
struct S;
fn foo(s: &&S) {}
fn main() {
    let mut ssss = &S;
    foo($0);
}
```

**Before this PR**

```rust
st S S []
lc ssss &S [local]
st S S []
fn foo(…) fn(&&S) []
fn main() fn() []
```

**After this PR**

```rust
st S S []
lc ssss &S [local]
lc &ssss [type+local]
st S S []
fn foo(…) fn(&&S) []
fn main() fn() []
```
2025-12-21 12:58:12 +08:00
A4-Tacks
f0055f6557
Add parent_match method to node_ext 2025-12-21 12:54:47 +08:00
Chayim Refael Friedman
e47b23dafe
Merge pull request #21293 from A4-Tacks/move-guard-no-apply-non-naked
Fix applicable on non naked if for move_guard assist
2025-12-21 04:38:36 +00:00
jackh726
f870ae8dc0 Review comments - some cleanups to get_failed_obligations, including returning a list 2025-12-21 01:05:36 +00:00
jackh726
0dd3fe029a Add lsp extension to get failed trait obligations for a given function 2025-12-20 22:43:58 +00:00
Chayim Refael Friedman
3ab0420c52 Replace some new() with new_from_args()
It's faster, when you already have a `GenericArgs`.
2025-12-20 19:21:57 +02:00
Chayim Refael Friedman
f91e54f7e5 Convert some <InternedSlice>::new_from_iter() to new_from_slice()
It's faster, when you have a slice available.
2025-12-20 19:08:26 +02:00
Chayim Refael Friedman
096ebb0759 Pre-intern some common types
This is possible now that they are no longer interned with Salsa.
2025-12-20 19:08:26 +02:00
Chayim Refael Friedman
d2a029ae05 Use slices for Interner::FnInputTys and Interner::GenericArgsSlice, not Tys and GenericArgs respectively
This allows us to avoid interning them.
2025-12-20 19:08:26 +02:00
Asuka Minato
a769fbdb87 fix
test case
2025-12-20 05:09:06 +09:00
Chayim Refael Friedman
5e2dfbbd02 Add extensive docs for the unsafe operations 2025-12-18 17:30:20 +02:00
Chayim Refael Friedman
36c9f6224c GC support for solver types
A GC is triggered every X revisions, and is synchronous, unfortunately.
2025-12-18 10:12:03 +02:00
Chayim Refael Friedman
776c818882 Lay the basics for non-Copy solver types with GC
That means stop using Salsa for interning solver types.
2025-12-18 10:12:03 +02:00
Jesung Yang
7f6858fd09 feat: introduce crate_attrs field in rust-project.json
Since the commit 50384460c68f
("Rewrite method resolution to follow rustc more closely"), the method
resolution logic has changed: rust-analyzer only looks up inherent
methods for primitive types in sysroot crates.

Unfortunately, this change broke at least one project that relies on
`rust-project.json`: Rust-for-Linux. Its auto-generated
`rust-project.json` directly embeds `core`, `alloc`, and `std` in the
`crates` list without defining `sysroot_src`. Consequently,
rust-analyzer fails to identify them as sysroot crates, breaking IDE
support for primitive methods (e.g., `0_i32.rotate_left(0)`).

However, specifying `sysroot_src` creates a new issue: it implicitly
adds `std` as a dependency to all kernel module crates, which are
actually compiled with `-Zcrate-attr=no_std`. Since rust-analyzer cannot
see compiler flags passed outside of the project definition, we need a
method to explicitly specify `#![no_std]` or, more generally,
crate-level attributes through the project configuration.

To resolve this, extend the `rust-project.json` format with a new
`crate_attrs` field. This allows users to specify crate-level attributes
such as `#![no_std]` directly into the configuration, enabling
rust-analyzer to respect them when analyzing crates.

References:
- The original Zulip discussion:
  https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Primitive.20type.20inherent.20method.20lookup.20fails/with/562983853
2025-12-18 01:27:43 +00:00
Jesung Yang
dd33c82f6b feat: pretty print attributes up to cfg(false)
Extend ItemTree pretty-printing to include attributes even when a cfg
expression evaluates to false, emitting explicit `cfg(cfg_expr)` marker
after the attributes.

This improves testability of ItemTree attribute handling by exposing
more information in pretty-printed output.
2025-12-18 00:16:34 +00:00
Chayim Refael Friedman
02f53e88cf
Merge pull request #21294 from ChayimFriedman2/lang-items-redundant
minor: Remove redundant things from the lang items macro
2025-12-17 11:28:18 +00:00
Chayim Refael Friedman
edd49164aa Remove redundant things from the lang items macro 2025-12-17 13:18:10 +02:00
Chayim Refael Friedman
34fd9f65a3
Merge pull request #21283 from ChayimFriedman2/upgrade-salsa
internal: Upgrade Salsa
2025-12-17 11:09:07 +00:00
Chayim Refael Friedman
4e54d37ba3 Upgrade Salsa
The new version gives an additional `salsa::Id` to cycle handlers, and renames `non_update_return_type` to `non_update_types`.
2025-12-17 12:59:30 +02:00
A4-Tacks
390d14bdc8
Fix applicable on non naked if for move_guard assist
Example
---
```rust
fn main() {
    match 92 {
        _ => {
            let cond = true;
            $0if cond {
                foo()
            }
        },
        _ => true
    }
}
```

**Before this PR**

```rust
fn main() {
    match 92 {
        _ if cond => foo(),
        _ => true
    }
}
```

**After this PR**

Assist not applicable
2025-12-17 17:53:52 +08:00
A4-Tacks
e1747f9ddf
Fix match arm nested body invalid expected type
Example
---
```rust
struct Foo;
enum E { X }
fn foo() -> Foo {
    match E::X { Foo::X => { $0 } }
}
```

**Before this PR**

```text
ty: E, name: ?
```

**After this PR**

```text
ty: Foo, name: ?
```
2025-12-17 17:35:33 +08:00
Chayim Refael Friedman
d7465cb5b7 Upgrade rustc crates
Changes:
 - `const_of_item()` was added to `Interner`, analogous to `type_of()`. No strongly-typed ID (yet).
 - New solver trait lang item: `TrivialClone`.
 - `TypeRelation` changed a bit, the code was copied from rustc.
2025-12-16 17:00:44 +02:00
Chayim Refael Friedman
92630ee98a
Merge pull request #21278 from A4-Tacks/mut-ref-type-match
Fix complete reference for `&mut ty` -> `&ty`
2025-12-16 08:52:33 +00:00
Chayim Refael Friedman
76cd4d6bf6
Merge pull request #21280 from ChayimFriedman2/fix-assert
minor: Fix an assert that didn't check what it should
2025-12-16 06:00:31 +00:00
Chayim Refael Friedman
14890be186 Fix an assert that didn't check what it should 2025-12-16 07:50:42 +02:00
Jesung Yang
55451d38ee internal: add special ErasedFileAstId used for bypassing downmapping
Introduce `NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER`, which prevents `Span`s
from being mapped down into macro expansions.

This is a preparatory step for adding a new field to the
`rust-project.json` format that can inject crate-level attributes.
`Span`s for those attributes will be marked with
`NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER`, indicating that they should not
be mapped down into macro expansions.
2025-12-16 05:23:53 +00:00
Chayim Refael Friedman
0023f193e6
Merge pull request #21277 from A4-Tacks/strip-deref
Fix expected type no strip deref
2025-12-16 03:30:06 +00:00
A4-Tacks
d13d63c0a7
Fix add reference for &mut ty -> &ty
Example
---
```rust
fn foo(r: &mut i32) -> &i32 { $0 }
```

**Before this PR**

`lc &r [type+local]`

This is a compilation error

```rust
fn foo(r: &mut i32) -> &i32 { &r }
```

**After this PR**

`lc r &mut i32 [type+local]`

```rust
fn foo(r: &mut i32) -> &i32 { r }
```
2025-12-16 11:00:10 +08:00
A4-Tacks
d359992184
Fix expected type no strip deref
Example
---
```rust
fn main() {
    let r = &2;
    let _: fn() -> i32 = || *$0;
}
```

**Before this PR**

`ty: &'_ u32, name: x`

```rust
fn main() {
    let r = &2;
    let _: fn() -> i32 = || **r;
}
```

**After this PR**

`ty: &'_ &'_ u32, name: x`

```rust
fn main() {
    let r = &2;
    let _: fn() -> i32 = || *r;
}
```
2025-12-16 10:20:40 +08:00
Chayim Refael Friedman
87cfc881f1
Merge pull request #21032 from A4-Tacks/no-semicolon-in-arg-list
Fix complete unit return semicolon in arg-list
2025-12-16 01:10:02 +00:00
Chayim Refael Friedman
b272c3568b
Merge pull request #21240 from benodiwal/feat/inlay-hint-missing-argument
feat: show parameter hint for missing arguments
2025-12-15 23:28:07 +00:00
Shoyu Vanilla (Flint)
ae15c7cc01
Merge pull request #21273 from ChayimFriedman2/dup-sysroot-method-resolution
fix: Fix method resolution for incoherent impls when there are two sysroots in the crate graph
2025-12-15 19:14:03 +00:00
Chayim Refael Friedman
de46a13f15
Merge pull request #21258 from A4-Tacks/fix-add-ret-function-in-closure
Fix not applicable fn in closure for add_return_type
2025-12-15 19:02:35 +00:00
Chayim Refael Friedman
0408c5a748
Merge pull request #21266 from A4-Tacks/prec-paren-replace-let-with-iflet
Fix invalid logic op for replace_let_with_if_let
2025-12-15 19:01:23 +00:00