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 https://github.com/rust-analyzer/rust-analyzer/issues/824

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2021-07-23 18:22:09 +00:00 committed by GitHub
commit 2e45e47c83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,7 +69,7 @@ fn complete_fields(
f(Either::Left(field), ty);
}
for (i, ty) in receiver.tuple_fields(ctx.db).into_iter().enumerate() {
// FIXME: Handle visibility
// Tuple fields are always public (tuple struct fields are handled above).
f(Either::Right(i), ty);
}
}
@ -213,6 +213,23 @@ fn foo(a: lib::m::A) { a.$0 }
"#]],
);
check(
r#"
//- /lib.rs crate:lib new_source_root:library
pub mod m {
pub struct A(
i32,
pub f64,
);
}
//- /main.rs crate:main deps:lib new_source_root:local
fn foo(a: lib::m::A) { a.$0 }
"#,
expect![[r#"
fd 1 f64
"#]],
);
check(
r#"
//- /lib.rs crate:lib new_source_root:local
@ -405,7 +422,24 @@ fn foo() {
fd 0 i32
fd 1 f64
"#]],
)
);
}
#[test]
fn test_tuple_struct_field_completion() {
check(
r#"
struct S(i32, f64);
fn foo() {
let b = S(0, 3.14);
b.$0
}
"#,
expect![[r#"
fd 0 i32
fd 1 f64
"#]],
);
}
#[test]