Skip to content

Commit 4570fad

Browse files
committed
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)) {} ```
1 parent 8192c63 commit 4570fad

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

crates/ide-completion/src/render/pattern.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ fn render_pat(
163163
PatternContext {
164164
param_ctx: Some(ParamContext { kind: ParamKind::Function(_), .. }),
165165
has_type_ascription: false,
166+
parent_pat: None,
166167
..
167168
}
168169
);

crates/ide-completion/src/tests/pattern.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,25 @@ fn foo($0) {}
398398
)
399399
}
400400

401+
#[test]
402+
fn completes_in_fn_param_in_nested_pattern() {
403+
check(
404+
r#"
405+
struct Foo { bar: Bar }
406+
struct Bar(u32);
407+
fn foo(Bar($0)) {}
408+
"#,
409+
expect![[r#"
410+
st Bar
411+
st Foo
412+
bn Bar(…) Bar($1)$0
413+
bn Foo {…} Foo { bar$1 }$0
414+
kw mut
415+
kw ref
416+
"#]],
417+
)
418+
}
419+
401420
#[test]
402421
fn completes_in_closure_param() {
403422
check(

0 commit comments

Comments
 (0)