mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
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 https://github.com/rust-analyzer/rust-analyzer/issues/824 bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
2e45e47c83
1 changed files with 36 additions and 2 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue