Commit Graph

725 Commits

Author SHA1 Message Date
Shoyu Vanilla (Flint)
87f5363056 Merge pull request #21750 from ChayimFriedman2/method-res-typingmode
fix: Do not use PostAnalysis TypingMode for IDE method resolution
2026-03-05 02:30:02 +00:00
Chayim Refael Friedman
398419b1e7 Do not use PostAnalysis TypingMode for IDE method resolution
As explained in the comments, PostAnalysis is good for most IDE things but not method resolution.

This fixes a bug which should not be impacted by this at all - return position impl trait in trait. It is currently lowered to an opaque, while it should be lowered to an anonymous associated type. But today when it is lowered as an opaque, this opaque of course has no definition and will normalize to an error, preventing method resolution on it from succeeding in some cases.
2026-03-04 22:06:36 +02:00
Chayim Refael Friedman
022f93973a Merge pull request #21671 from A4-Tacks/postfix-tree-climbing
fix: offer block `.let` in ref-expr in match arm
2026-03-04 08:10:24 +00:00
A4-Tacks
423c466df5 fix: no complete enum variant qualifier in pat
Example
---
```rust
enum Enum { TupleV(u32), RecordV { field: u32 }, UnitV }
use Enum::*;
fn func() {
    if let $0 = unknown {}
}
```

**Before this PR**

```text
...
ev RecordV
ev TupleV
ev UnitV
bn RecordV {…} RecordV { field$1 }$0
bn TupleV(…)            TupleV($1)$0
bn UnitV                     UnitV$0
kw mut
kw ref
```

**After this PR**

```text
...
bn RecordV {…} RecordV { field$1 }$0
bn TupleV(…)            TupleV($1)$0
bn UnitV                     UnitV$0
kw mut
kw ref
```
2026-02-25 20:52:50 +08:00
A4-Tacks
cd21e9b9d9 fix: offer block .let in ref-expr in match arm
Example
---
```rust
fn main() {
    match 2 {
        bar => &bar.l$0
    }
}
```

**Before this PR**

```text
sn deref         *expr
sn match match expr {}
```

**After this PR**

```text
sn deref         *expr
sn let             let
sn letm        let mut
sn match match expr {}
```
2026-02-21 09:03:21 +08:00
A4-Tacks
1a1b624c51 Fix some TryEnum reference assists
- Fix `convert_to_guarded_return`
- Fix `replace_let_with_if_let`
- Fix `replace_if_let_with_match`
2026-02-19 10:43:03 +08:00
Chayim Refael Friedman
3cf298f9a9 Merge pull request #21594 from A4-Tacks/fallback-let-comp-block
feat: offer block let fallback postfix complete
2026-02-18 13:03:07 +00:00
A4-Tacks
05fc0e6679 Only offer block let fallback in match-arm 2026-02-18 20:34:08 +08:00
Chayim Refael Friedman
3ad9e7d57f Merge pull request #21598 from A4-Tacks/minor-postfix-double-call
internal: remove redundant double call in postfix
2026-02-18 01:43:54 +00:00
Chayim Refael Friedman
715ce300ac Merge pull request #21600 from A4-Tacks/let-in-prefix
fix: complete `.let` on block tail prefix expression
2026-02-18 01:42:39 +00:00
Chayim Refael Friedman
02c23ee3fd Merge pull request #21650 from A4-Tacks/not-suggest-param-in-pat
fix: no complete suggest param in complex pattern
2026-02-18 01:38:38 +00:00
A4-Tacks
4c6d38b6da fix: complete derive helpers on empty nameref
Example
---
```rust
//- /mac.rs crate:mac

pub fn my_derive() {}

//- /lib.rs crate:lib deps:mac
pub struct Foo(#[$0] i32);
```

**Before this PR**

```text
...
at must_use
at no_mangle
...
```

**After this PR**

```text
...
at must_use
at my_cool_helper_attribute derive helper of `MyDerive`
at no_mangle
...
```
2026-02-16 18:23:35 +08:00
A4-Tacks
a86a0bc568 fix: no complete suggest param in complex pattern
Example
---
```rust
fn foo(bar: u32) {}
fn bar((a, bar$0)) {}
```

**Before this PR**

```rust
fn foo(bar: u32) {}
fn bar(bar: u32)) {}
```

**After this PR**

Not complete `bar: u32`
2026-02-15 22:09:05 +08:00
A4-Tacks
75f211ce45 internal: to use SmolStr in fn_param 2026-02-15 22:08:31 +08:00
Chayim Refael Friedman
2a16118416 Merge pull request #21402 from A4-Tacks/no-semicolon-array
Fix complete semicolon in array expression
2026-02-12 20:10:46 +00:00
A4-Tacks
7450dabecc fix: complete .let on block tail prefix expression
Example
---
```rust
fn main() {
    &baz.l$0
}
```

**Before this PR**

```text
sn if       if expr {}
sn match match expr {}
```

**After this PR**

```text
sn if       if expr {}
sn let             let
sn letm        let mut
sn match match expr {}
```
2026-02-07 18:05:18 +08:00
A4-Tacks
a6b943b1ac internal: remove redundant double call in postfix 2026-02-07 16:09:00 +08:00
A4-Tacks
176590ed3a feat: offer block let fallback postfix complete
Example
---
```rust
fn main() {
    match 2 {
        bar => bar.$0
    }
}
```
->
```rust
fn main() {
    match 2 {
        bar => {
            let $1 = bar;
            $0
        }
    }
}
```
2026-02-06 16:24:35 +08:00
A4-Tacks
48ab21edd3 fix: Fix not complete .not in condition
Example
---
```rust
fn foo(cond: bool) {
    if cond.$0
}
```

**Before this PR**

```text
...
sn deref         *expr
sn ref           &expr
...
```

**After this PR**

```text
...
sn deref         *expr
sn not           !expr
sn ref           &expr
...
```
2026-02-03 17:47:48 +08:00
A4-Tacks
f13c3d2fab feat: fallback let postfix completions in condition
Easy to input other patterns, or bind variable in let-chain

Example
---
```rust
fn main() {
    let bar = 2;
    if bar.$0
}
```

**Before this PR**

No complete 'let'

**After this PR**

```rust
fn main() {
    let bar = 2;
    if let $1 = bar
}
```
2026-01-31 06:04:16 +08:00
A4-Tacks
259f94b3eb fix: complete inferred type in static
Example
---
```rust
struct Foo<T>(T);
static FOO: $0 = Foo(2);
```

**Before this PR**

```text
...
bt u32                      u32
...
```

**After this PR**

```text
...
bt u32                      u32
it Foo<i32>
...
```
2026-01-29 13:48:08 +08:00
kouhe
8c5a9ebc61 Implement default field values .. syntax
- Added `RecordSpread` enum to distinguish between no spread, field defaults, and spread expressions
- Updated `FieldData` to include `default_value` field
- Modified record literal lowering to handle default field values
- Updated diagnostics to check for missing fields considering defaults
- Added methods to get matched fields for records for completions
- Enhanced hover support for struct rest patterns
2026-01-26 19:01:21 +08:00
A4-Tacks
cc725f8cbc Fix not complete 'else' before tuple
Example
---
```rust
fn foo() -> (i32, i32) {
    if foo {} el$0
    (2, 3)
}
```

**Before this PR**

```rust
...
kw crate::
kw false
kw for
...
```

**After this PR**

```rust
...
kw crate::
kw else
kw else if
kw false
kw for
...
```
2026-01-26 13:35:48 +08:00
Shoyu Vanilla (Flint)
ec64ea0296 Merge pull request #21451 from A4-Tacks/comp-ref-mut-before-method-call
Fix not complete `mut` and `raw` in `&x.foo()`
2026-01-13 07:12:08 +00:00
A4-Tacks
5ba2505f3e Fix not complete mut and raw in &x.foo()
Example
---
```rust
fn main() {
    let _ = &$0x.foo();
}
```

**Before this PR**

```rust
...
kw loop
kw match
kw return
kw self::
...
```

**After this PR**

```rust
...
kw loop
kw match
kw mut
kw raw
kw return
kw self::
...
```
2026-01-12 20:28:19 +08:00
Lukas Wirth
d90e7b6577 Create a new SymbolKind::CrateRoot 2026-01-12 08:46:20 +01:00
Wilfred Hughes
9c0d88cc07 internal: Include private definitions in generated rustdoc
rust-analyzer has handy prebuilt `cargo doc` output at
https://rust-lang.github.io/rust-analyzer/ide/

However, it doesn't include private definitions, which makes it less
useful when trying to learn unfamiliar parts of the codebase.

Instead, pass `--document-private-items` so the HTML includes
information on private types and modules too. rustdoc renders these
with a padlock icon, so it's still clear that they're private.

This change also exposes some more rustdoc warnings, which I've fixed.
2026-01-09 12:01:54 +00:00
Hendrik Lind
987433d8a9 fix: use crates where ADT was defined in deref_chain of trait_applicable_items 2026-01-06 20:49:14 +01:00
A4-Tacks
a5811ccd30 Fix complete semicolon in array expression
Example
---
```rust
fn foo() {}
fn bar() {
    let _ = [fo$0];
}
```

**Before this PR**

```rust
fn foo() {}
fn bar() {
    let _ = [foo();$0];
}
```

**After this PR**

```rust
fn foo() {}
fn bar() {
    let _ = [foo()$0];
}
```
2026-01-04 20:54:59 +08:00
Lukas Wirth
8facf7344d perf: Only compute lang items for #![feature(lang_items)] crates 2026-01-03 11:06:33 +01:00
Lukas Wirth
439c095212 Reduce impl_signature query dependencies in method resolution 2026-01-02 15:09:20 +01:00
Chayim Refael Friedman
55a083cacb Add #[rust_analyzer::macro_style()] attribute to control macro completion brace style 2025-12-30 22:44:18 +02:00
Lukas Wirth
38271f5111 Merge pull request #21354 from A4-Tacks/dedup-record-update
Fix duplicate record functional update
2025-12-28 13:13:04 +00:00
A4-Tacks
57384b1f59 Fix duplicate record functional update
Example
---
```rust
fn main() {
    let thing = 1;
    let foo = Foo { foo1: 0, foo2: 0 };
    let foo2 = Foo { thing, $0 ..Default::default() }
}
```

**Before this PR**

```text
fd ..Default::default()
fd foo1             u32
fd foo2             u32
```

**After this PR**

```text
fd foo1 u32
fd foo2 u32
```
2025-12-28 17:34:34 +08:00
Chayim Refael Friedman
32028ab176 Fix tests that relied on the default variance to be invariant
And now it changed to bivariant.
2025-12-27 20:06:24 +02:00
A4-Tacks
d2cc89ffc7 Add macro segment completion
Example
---
```rust
macro_rules! foo {
    ($($x:$0)*) => ();
}
```

**Completion items**:

```text
ba block
ba expr
ba expr_2021
ba ident
ba item
ba lifetime
ba literal
ba meta
ba pat
ba pat_param
ba path
ba stmt
ba tt
ba ty
ba vis
```
2025-12-27 05:04:18 +08:00
A4-Tacks
ac01f880d7 Add BreakExpr completion suggest
- Move `ide::goto_definition::find_loops`
  into `ide_db::syntax_helpers::node_ext::find_loops`
2025-12-22 20:13:56 +08: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
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
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
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
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
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