aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/references.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-10 08:50:57 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-10 08:50:57 +0100
commit37eb12f2dd6f36570a27b4e4aaf9048860b5a06b (patch)
treef5640991cbf0db2bfdad29b911435827cadfb4a8 /crates/ra_ide_api/src/references.rs
parentb863272899a1bae63c7d9411d0ebff74652bae8e (diff)
parent10726fdb65fda9144a5f9201272d065a268fc1b7 (diff)
Merge #1128
1128: A touch of type-safety r=matklad a=matklad Note that we intentionally don't use `Either` from crates.io: I like A/B naming more then left/rigth, I feel like we might need Either3 with C at some point, and I'd love the ability to write inherent impls Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/references.rs')
-rw-r--r--crates/ra_ide_api/src/references.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 20bbf11a3..3e30e047c 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -1,5 +1,5 @@
1use relative_path::{RelativePath, RelativePathBuf}; 1use relative_path::{RelativePath, RelativePathBuf};
2use hir::{ModuleSource, source_binder}; 2use hir::{ModuleSource, source_binder, Either};
3use ra_db::{SourceDatabase}; 3use ra_db::{SourceDatabase};
4use ra_syntax::{ 4use ra_syntax::{
5 AstNode, SyntaxNode, SourceFile, 5 AstNode, SyntaxNode, SourceFile,
@@ -89,9 +89,12 @@ pub(crate) fn find_all_refs(
89 source_binder::function_from_child_node(db, position.file_id, name_ref.syntax())?; 89 source_binder::function_from_child_node(db, position.file_id, name_ref.syntax())?;
90 let scope = descr.scopes(db); 90 let scope = descr.scopes(db);
91 let resolved = scope.resolve_local_name(name_ref)?; 91 let resolved = scope.resolve_local_name(name_ref)?;
92 let resolved = resolved.ptr().to_node(source_file); 92 if let Either::A(ptr) = resolved.ptr() {
93 let binding = find_node_at_offset::<ast::BindPat>(syntax, resolved.range().end())?; 93 if let ast::PatKind::BindPat(binding) = ptr.to_node(source_file).kind() {
94 Some((binding, descr)) 94 return Some((binding, descr));
95 }
96 }
97 None
95 } 98 }
96} 99}
97 100