diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_dot.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 32fd497be..07007d03f 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -46,13 +46,14 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | Ty::Tuple(fields) => { | 48 | Ty::Tuple(fields) => { |
49 | for (i, _ty) in fields.iter().enumerate() { | 49 | for (i, ty) in fields.iter().enumerate() { |
50 | CompletionItem::new( | 50 | CompletionItem::new( |
51 | CompletionKind::Reference, | 51 | CompletionKind::Reference, |
52 | ctx.source_range(), | 52 | ctx.source_range(), |
53 | i.to_string(), | 53 | i.to_string(), |
54 | ) | 54 | ) |
55 | .kind(CompletionItemKind::Field) | 55 | .kind(CompletionItemKind::Field) |
56 | .detail(ty.to_string()) | ||
56 | .add_to(acc); | 57 | .add_to(acc); |
57 | } | 58 | } |
58 | } | 59 | } |
@@ -174,4 +175,17 @@ mod tests { | |||
174 | ", | 175 | ", |
175 | ); | 176 | ); |
176 | } | 177 | } |
178 | |||
179 | #[test] | ||
180 | fn test_tuple_field_completion() { | ||
181 | check_ref_completion( | ||
182 | "tuple_field_completion", | ||
183 | r" | ||
184 | fn foo() { | ||
185 | let b = (0, 3.14); | ||
186 | b.<|> | ||
187 | } | ||
188 | ", | ||
189 | ); | ||
190 | } | ||
177 | } | 191 | } |