mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
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:
parent
8192c6345f
commit
408b8bcc4a
2 changed files with 20 additions and 0 deletions
|
|
@ -163,6 +163,7 @@ fn render_pat(
|
|||
PatternContext {
|
||||
param_ctx: Some(ParamContext { kind: ParamKind::Function(_), .. }),
|
||||
has_type_ascription: false,
|
||||
parent_pat: None,
|
||||
..
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue