Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/tests/record.rs')
-rw-r--r--crates/ide-completion/src/tests/record.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/crates/ide-completion/src/tests/record.rs b/crates/ide-completion/src/tests/record.rs
index ddb9294469..aecf8eb651 100644
--- a/crates/ide-completion/src/tests/record.rs
+++ b/crates/ide-completion/src/tests/record.rs
@@ -157,6 +157,8 @@ fn foo(f: Struct) {
fn in_functional_update() {
cov_mark::check!(functional_update);
+ // FIXME: This should filter out all completions that do not have the type `Foo`
+ // I think maybe ranking by type match is enough
check(
r#"
//- minicore:default
@@ -210,7 +212,6 @@ fn main() {
#[test]
fn functional_update_no_dot() {
cov_mark::check!(functional_update_field);
- // FIXME: This should filter out all completions that do not have the type `Foo`
check(
r#"
//- minicore:default
@@ -281,6 +282,48 @@ fn main() {
}
#[test]
+fn functional_update_non_last() {
+ check(
+ r#"
+//- minicore:default
+struct Foo { foo1: u32, foo2: u32 }
+impl Default for Foo {
+ fn default() -> Self { loop {} }
+}
+
+fn main() {
+ let thing = 1;
+ let foo = Foo { foo1: 0, foo2: 0 };
+ let foo2 = Foo { $0 thing }
+}
+"#,
+ expect![[r#"
+ fd foo1 u32
+ fd foo2 u32
+ "#]],
+ );
+ check(
+ r#"
+//- minicore:default
+struct Foo { foo1: u32, foo2: u32 }
+impl Default for Foo {
+ fn default() -> Self { loop {} }
+}
+
+fn main() {
+ let thing = 1;
+ let foo = Foo { foo1: 0, foo2: 0 };
+ let foo2 = Foo { $0thing }
+}
+"#,
+ expect![[r#"
+ fd foo1 u32
+ fd foo2 u32
+ "#]],
+ );
+}
+
+#[test]
fn functional_update_fields_completion() {
// Complete fields before functional update `..`
check(