From af2366acdf1321702e54e01c88052ed5a674716c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Mar 2021 15:02:48 +0300 Subject: 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. --- crates/ide/src/goto_definition.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/ide') 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 @@ -1158,6 +1158,17 @@ struct S; //- /m.rs //! [`super::S$0`] +"#, + ) + } + + #[test] + fn goto_incomplete_field() { + check( + r#" +struct A { a: u32 } + //^ +fn foo() { A { a$0: }; } "#, ) } -- cgit v1.2.3