Deduplicate tuple indices for completion
This commit is contained in:
parent
42eab5e100
commit
d01283b1f7
@ -113,8 +113,12 @@ fn complete_fields(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i, ty) in receiver.tuple_fields(ctx.db).into_iter().enumerate() {
|
for (i, ty) in receiver.tuple_fields(ctx.db).into_iter().enumerate() {
|
||||||
// Tuple fields are always public (tuple struct fields are handled above).
|
// Tuples are always the last type in a deref chain, so just check if the name is
|
||||||
tuple_index(acc, i, ty);
|
// already seen without inserting into the hashset.
|
||||||
|
if !seen_names.contains(&hir::Name::new_tuple_field(i)) {
|
||||||
|
// Tuple fields are always public (tuple struct fields are handled above).
|
||||||
|
tuple_index(acc, i, ty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -720,6 +724,28 @@ fn test(a: A) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tuple_struct_deref_to_tuple_no_same_index() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
//- minicore: deref
|
||||||
|
struct A(u8);
|
||||||
|
impl core::ops::Deref for A {
|
||||||
|
type Target = (u16, u32);
|
||||||
|
fn deref(&self) -> &Self::Target { loop {} }
|
||||||
|
}
|
||||||
|
fn test(a: A) {
|
||||||
|
a.$0
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
fd 0 u8
|
||||||
|
fd 1 u32
|
||||||
|
me deref() (use core::ops::Deref) fn(&self) -> &<Self as Deref>::Target
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_completion_works_in_consts() {
|
fn test_completion_works_in_consts() {
|
||||||
check(
|
check(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user