File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
crates/ide-completion/src/completions Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,12 @@ fn complete_fields(
113
113
}
114
114
}
115
115
for ( i, ty) in receiver. tuple_fields ( ctx. db ) . into_iter ( ) . enumerate ( ) {
116
- // Tuple fields are always public (tuple struct fields are handled above).
117
- tuple_index ( acc, i, ty) ;
116
+ // Tuples are always the last type in a deref chain, so just check if the name is
117
+ // already seen without inserting into the hashset.
118
+ if !seen_names. contains ( & hir:: Name :: new_tuple_field ( i) ) {
119
+ // Tuple fields are always public (tuple struct fields are handled above).
120
+ tuple_index ( acc, i, ty) ;
121
+ }
118
122
}
119
123
}
120
124
}
@@ -720,6 +724,28 @@ fn test(a: A) {
720
724
) ;
721
725
}
722
726
727
+ #[ test]
728
+ fn test_tuple_struct_deref_to_tuple_no_same_index ( ) {
729
+ check (
730
+ r#"
731
+ //- minicore: deref
732
+ struct A(u8);
733
+ impl core::ops::Deref for A {
734
+ type Target = (u16, u32);
735
+ fn deref(&self) -> &Self::Target { loop {} }
736
+ }
737
+ fn test(a: A) {
738
+ a.$0
739
+ }
740
+ "# ,
741
+ expect ! [ [ r#"
742
+ fd 0 u8
743
+ fd 1 u32
744
+ me deref() (use core::ops::Deref) fn(&self) -> &<Self as Deref>::Target
745
+ "# ] ] ,
746
+ ) ;
747
+ }
748
+
723
749
#[ test]
724
750
fn test_completion_works_in_consts ( ) {
725
751
check (
You can’t perform that action at this time.
0 commit comments