Skip to content

Commit 2e45e47

Browse files
Merge #9685
9685: internal: add tests for tuple struct field completion and resolve a FIXME r=jonas-schievink a=jonas-schievink This removes the last FIXME related to visibility and thus fixes #824 bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 661961c + c495a73 commit 2e45e47

File tree

1 file changed

+36
-2
lines changed
  • crates/ide_completion/src/completions

1 file changed

+36
-2
lines changed

crates/ide_completion/src/completions/dot.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn complete_fields(
6969
f(Either::Left(field), ty);
7070
}
7171
for (i, ty) in receiver.tuple_fields(ctx.db).into_iter().enumerate() {
72-
// FIXME: Handle visibility
72+
// Tuple fields are always public (tuple struct fields are handled above).
7373
f(Either::Right(i), ty);
7474
}
7575
}
@@ -213,6 +213,23 @@ fn foo(a: lib::m::A) { a.$0 }
213213
"#]],
214214
);
215215

216+
check(
217+
r#"
218+
//- /lib.rs crate:lib new_source_root:library
219+
pub mod m {
220+
pub struct A(
221+
i32,
222+
pub f64,
223+
);
224+
}
225+
//- /main.rs crate:main deps:lib new_source_root:local
226+
fn foo(a: lib::m::A) { a.$0 }
227+
"#,
228+
expect![[r#"
229+
fd 1 f64
230+
"#]],
231+
);
232+
216233
check(
217234
r#"
218235
//- /lib.rs crate:lib new_source_root:local
@@ -405,7 +422,24 @@ fn foo() {
405422
fd 0 i32
406423
fd 1 f64
407424
"#]],
408-
)
425+
);
426+
}
427+
428+
#[test]
429+
fn test_tuple_struct_field_completion() {
430+
check(
431+
r#"
432+
struct S(i32, f64);
433+
fn foo() {
434+
let b = S(0, 3.14);
435+
b.$0
436+
}
437+
"#,
438+
expect![[r#"
439+
fd 0 i32
440+
fd 1 f64
441+
"#]],
442+
);
409443
}
410444

411445
#[test]

0 commit comments

Comments
 (0)