Unnamed repository; edit this file 'description' to name the repository.
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)) {} ```
A4-Tacks 7 months ago
parent 8192c63 · commit 408b8bc
-rw-r--r--crates/ide-completion/src/render/pattern.rs1
-rw-r--r--crates/ide-completion/src/tests/pattern.rs19
2 files changed, 20 insertions, 0 deletions
diff --git a/crates/ide-completion/src/render/pattern.rs b/crates/ide-completion/src/render/pattern.rs
index 60ec112823..312d3bd426 100644
--- a/crates/ide-completion/src/render/pattern.rs
+++ b/crates/ide-completion/src/render/pattern.rs
@@ -163,6 +163,7 @@ fn render_pat(
PatternContext {
param_ctx: Some(ParamContext { kind: ParamKind::Function(_), .. }),
has_type_ascription: false,
+ parent_pat: None,
..
}
);
diff --git a/crates/ide-completion/src/tests/pattern.rs b/crates/ide-completion/src/tests/pattern.rs
index 9ec27252fd..6eb0b818d6 100644
--- a/crates/ide-completion/src/tests/pattern.rs
+++ b/crates/ide-completion/src/tests/pattern.rs
@@ -399,6 +399,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(
r#"