diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-22 05:32:48 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-22 05:32:48 +0000 |
commit | 9c6c6a7cb51b701585827c1a39d36450ddb5cd51 (patch) | |
tree | c5e4c46da389accd0b03b3b285f5057265f65f65 /crates/ra_ide_api/src/goto_definition.rs | |
parent | 51323a852a8979a71c21725b3b2771224132b85f (diff) | |
parent | 1ee779d1f74f48d9f3098001c63108b794dbc0b5 (diff) |
Merge #988
988: Consolidate Ty variants into a new variant Ty::Apply r=matklad a=flodiebold
This gets us a lot closer to Chalk. It also introduces a lot of boilerplate, though, especially when matching :/ A lot of this can probably be refactored to be nicer, though.
Co-authored-by: Florian Diebold <[email protected]>
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 | } |