aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-06 00:24:11 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-06 00:24:11 +0100
commit990e74ba7c77485f914434ac6f09a40d1364634d (patch)
tree9e979e9ec084d717db9d4326df3a970db8d28947 /crates/ra_ide_api/src
parent9d39b7bc42e6186b0fd6e1cec746d58c950f780e (diff)
parent2caa690ef6feba3f78354e715deea37983b149ac (diff)
Merge #1117
1117: [WIP] Tuple struct index inference r=matklad a=robojumper The first commit adds a helper struct `ast::FieldKind` to facilitate inference. The second commit adds a slightly modified test from #1109 while mentioning that there is a problem with how we're handling tuple indexing / floats. cc #1109 Co-authored-by: robojumper <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs22
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_inference.snap16
2 files changed, 38 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index f54a02d1d..18b2d68d5 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -184,4 +184,26 @@ mod tests {
184 ", 184 ",
185 ); 185 );
186 } 186 }
187
188 #[test]
189 fn test_tuple_field_inference() {
190 check_ref_completion(
191 "tuple_field_inference",
192 r"
193 pub struct S;
194 impl S {
195 pub fn blah(&self) {}
196 }
197
198 struct T(S);
199
200 impl T {
201 fn foo(&self) {
202 // FIXME: This doesn't work without the trailing `a` as `0.` is a float
203 self.0.a<|>
204 }
205 }
206 ",
207 );
208 }
187} 209}
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_inference.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_inference.snap
new file mode 100644
index 000000000..72c8973b8
--- /dev/null
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_inference.snap
@@ -0,0 +1,16 @@
1---
2created: "2019-04-05T23:00:18.283812700Z"
3creator: [email protected]
4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions
6---
7[
8 CompletionItem {
9 label: "blah",
10 source_range: [299; 300),
11 delete: [299; 300),
12 insert: "blah()$0",
13 kind: Method,
14 detail: "pub fn blah(&self)"
15 }
16]