diff options
author | Aleksey Kladov <[email protected]> | 2021-03-15 12:02:48 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-03-15 12:12:39 +0000 |
commit | af2366acdf1321702e54e01c88052ed5a674716c (patch) | |
tree | 5a9d98a215a2adf82dbd2d3c9b74602e0c7debf8 /crates/ide/src | |
parent | 5138baf2ac742de601f29d22fc64e386da56c4c2 (diff) |
Goto definition works for `S { a: }` case
What happens here is that we lower `: ` to a missing expression, and
then correctly record that the corresponding field expression resolves
to a specific field. Where we fail is in the mapping of syntax to this
missing expression. Doing it via `ast_field.expr()` fails, as that
expression is `None`. Instead, we go in the opposite direcition and ask
each lowered field about its source.
This works, but has wrong complexity `O(N)` and, really, the
implementation is just too complex. We need some better management of
data here.
Diffstat (limited to 'crates/ide/src')
-rw-r--r-- | crates/ide/src/goto_definition.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index abed1969e..e8f31e4b1 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -1161,4 +1161,15 @@ struct S; | |||
1161 | "#, | 1161 | "#, |
1162 | ) | 1162 | ) |
1163 | } | 1163 | } |
1164 | |||
1165 | #[test] | ||
1166 | fn goto_incomplete_field() { | ||
1167 | check( | ||
1168 | r#" | ||
1169 | struct A { a: u32 } | ||
1170 | //^ | ||
1171 | fn foo() { A { a$0: }; } | ||
1172 | "#, | ||
1173 | ) | ||
1174 | } | ||
1164 | } | 1175 | } |