Fix complete type in nested pattern

Example
---
```rust
struct Foo { num: u32 }
struct Bar(Foo);
fn foo(Bar($0)) {}
```

**Before this PR**:

```rust
struct Foo { num: u32 }
struct Bar(Foo);
fn foo(Bar(Foo { num$1 }: Foo$0)) {}
```

**After this PR**:

```rust
struct Foo { num: u32 }
struct Bar(Foo);
fn foo(Bar(Foo { num$1 }$0)) {}
```
This commit is contained in:
A4-Tacks 2025-09-17 14:59:02 +08:00
parent 8192c6345f
commit 408b8bcc4a
No known key found for this signature in database
GPG key ID: DBD861323040663B
2 changed files with 20 additions and 0 deletions

View file

@ -163,6 +163,7 @@ fn render_pat(
PatternContext {
param_ctx: Some(ParamContext { kind: ParamKind::Function(_), .. }),
has_type_ascription: false,
parent_pat: None,
..
}
);

View file

@ -398,6 +398,25 @@ fn foo($0) {}
)
}
#[test]
fn completes_in_fn_param_in_nested_pattern() {
check(
r#"
struct Foo { num: u32 }
struct Bar(Foo);
fn foo(Bar($0)) {}
"#,
expect![[r#"
st Bar
st Foo
bn Bar() Bar($1)$0
bn Foo {} Foo { num$1 }$0
kw mut
kw ref
"#]],
)
}
#[test]
fn completes_in_closure_param() {
check(