aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/goto_type_definition.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/ide/src/goto_type_definition.rs b/crates/ide/src/goto_type_definition.rs
index f3284bb96..004d9cb68 100644
--- a/crates/ide/src/goto_type_definition.rs
+++ b/crates/ide/src/goto_type_definition.rs
@@ -1,3 +1,4 @@
1use ide_db::base_db::Upcast;
1use ide_db::RootDatabase; 2use ide_db::RootDatabase;
2use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; 3use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
3 4
@@ -31,6 +32,7 @@ pub(crate) fn goto_type_definition(
31 ast::Pat(it) => sema.type_of_pat(&it)?, 32 ast::Pat(it) => sema.type_of_pat(&it)?,
32 ast::SelfParam(it) => sema.type_of_self(&it)?, 33 ast::SelfParam(it) => sema.type_of_self(&it)?,
33 ast::Type(it) => sema.resolve_type(&it)?, 34 ast::Type(it) => sema.resolve_type(&it)?,
35 ast::RecordField(it) => sema.to_def(&it).map(|d| d.ty(db.upcast()))?,
34 _ => return None, 36 _ => return None,
35 } 37 }
36 }; 38 };
@@ -161,4 +163,34 @@ impl Foo$0 {}
161"#, 163"#,
162 ) 164 )
163 } 165 }
166
167 #[test]
168 fn goto_def_for_struct_field() {
169 check(
170 r#"
171struct Bar;
172 //^^^
173
174struct Foo {
175 bar$0: Bar,
176}
177"#,
178 );
179 }
180
181 #[test]
182 fn goto_def_for_enum_struct_field() {
183 check(
184 r#"
185struct Bar;
186 //^^^
187
188enum Foo {
189 Bar {
190 bar$0: Bar
191 },
192}
193"#,
194 );
195 }
164} 196}