diff options
Diffstat (limited to 'crates/ra_ide_api/src/goto_definition.rs')
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index d4e10b69c..f94487d94 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -87,14 +87,12 @@ pub(crate) fn reference_definition( | |||
87 | 87 | ||
88 | if let Some(expr) = struct_lit.and_then(|lit| source_map.node_expr(lit.into())) { | 88 | if let Some(expr) = struct_lit.and_then(|lit| source_map.node_expr(lit.into())) { |
89 | let ty = infer_result[expr].clone(); | 89 | let ty = infer_result[expr].clone(); |
90 | if let hir::Ty::Adt { def_id, .. } = ty { | 90 | if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() { |
91 | if let hir::AdtDef::Struct(s) = def_id { | 91 | let hir_path = hir::Path::from_name_ref(name_ref); |
92 | let hir_path = hir::Path::from_name_ref(name_ref); | 92 | let hir_name = hir_path.as_ident().unwrap(); |
93 | let hir_name = hir_path.as_ident().unwrap(); | ||
94 | 93 | ||
95 | if let Some(field) = s.field(db, hir_name) { | 94 | if let Some(field) = s.field(db, hir_name) { |
96 | return Exact(NavigationTarget::from_field(db, field)); | 95 | return Exact(NavigationTarget::from_field(db, field)); |
97 | } | ||
98 | } | 96 | } |
99 | } | 97 | } |
100 | } | 98 | } |
@@ -124,7 +122,7 @@ pub(crate) fn reference_definition( | |||
124 | Some(Resolution::SelfType(impl_block)) => { | 122 | Some(Resolution::SelfType(impl_block)) => { |
125 | let ty = impl_block.target_ty(db); | 123 | let ty = impl_block.target_ty(db); |
126 | 124 | ||
127 | if let hir::Ty::Adt { def_id, .. } = ty { | 125 | if let Some((def_id, _)) = ty.as_adt() { |
128 | return Exact(NavigationTarget::from_adt_def(db, def_id)); | 126 | return Exact(NavigationTarget::from_adt_def(db, def_id)); |
129 | } | 127 | } |
130 | } | 128 | } |