aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r--crates/ra_analysis/src/completion/mod.rs5
-rw-r--r--crates/ra_analysis/src/descriptors/module/mod.rs11
-rw-r--r--crates/ra_analysis/src/imp.rs10
-rw-r--r--crates/ra_analysis/src/lib.rs9
4 files changed, 13 insertions, 22 deletions
diff --git a/crates/ra_analysis/src/completion/mod.rs b/crates/ra_analysis/src/completion/mod.rs
index c7717ab61..5ef278127 100644
--- a/crates/ra_analysis/src/completion/mod.rs
+++ b/crates/ra_analysis/src/completion/mod.rs
@@ -38,10 +38,7 @@ pub(crate) fn completions(
38 original_file.reparse(&edit) 38 original_file.reparse(&edit)
39 }; 39 };
40 40
41 let module = match ModuleDescriptor::guess_from_position(db, position)? { 41 let module = ctry!(ModuleDescriptor::guess_from_position(db, position)?);
42 None => return Ok(None),
43 Some(it) => it,
44 };
45 42
46 let mut res = Vec::new(); 43 let mut res = Vec::new();
47 let mut has_completions = false; 44 let mut has_completions = false;
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs
index 51bc84bf1..764e19ce0 100644
--- a/crates/ra_analysis/src/descriptors/module/mod.rs
+++ b/crates/ra_analysis/src/descriptors/module/mod.rs
@@ -17,7 +17,7 @@ use crate::{
17 descriptors::{Path, PathKind, DescriptorDatabase}, 17 descriptors::{Path, PathKind, DescriptorDatabase},
18 input::SourceRootId, 18 input::SourceRootId,
19 arena::{Arena, Id}, 19 arena::{Arena, Id},
20 loc2id::DefLoc, 20 loc2id::{DefLoc, DefId},
21}; 21};
22 22
23pub(crate) use self::nameres::ModuleScope; 23pub(crate) use self::nameres::ModuleScope;
@@ -153,15 +153,6 @@ impl ModuleDescriptor {
153 db: &impl DescriptorDatabase, 153 db: &impl DescriptorDatabase,
154 path: Path, 154 path: Path,
155 ) -> Cancelable<Option<ModuleDescriptor>> { 155 ) -> Cancelable<Option<ModuleDescriptor>> {
156 macro_rules! ctry {
157 ($expr:expr) => {
158 match $expr {
159 None => return Ok(None),
160 Some(it) => it,
161 }
162 };
163 };
164
165 let mut curr = match path.kind { 156 let mut curr = match path.kind {
166 PathKind::Crate => self.crate_root(), 157 PathKind::Crate => self.crate_root(),
167 PathKind::Self_ | PathKind::Plain => self.clone(), 158 PathKind::Self_ | PathKind::Plain => self.clone(),
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index ad6b52371..8a41b3152 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -450,14 +450,8 @@ impl AnalysisImpl {
450 let syntax = file.syntax(); 450 let syntax = file.syntax();
451 451
452 // Find the calling expression and it's NameRef 452 // Find the calling expression and it's NameRef
453 let calling_node = match FnCallNode::with_node(syntax, position.offset) { 453 let calling_node = ctry!(FnCallNode::with_node(syntax, position.offset));
454 Some(node) => node, 454 let name_ref = ctry!(calling_node.name_ref());
455 None => return Ok(None),
456 };
457 let name_ref = match calling_node.name_ref() {
458 Some(name) => name,
459 None => return Ok(None),
460 };
461 455
462 // Resolve the function's NameRef (NOTE: this isn't entirely accurate). 456 // Resolve the function's NameRef (NOTE: this isn't entirely accurate).
463 let file_symbols = self.index_resolve(name_ref)?; 457 let file_symbols = self.index_resolve(name_ref)?;
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index cedbd1fc8..0fbfd8a40 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -9,6 +9,15 @@ extern crate relative_path;
9extern crate rustc_hash; 9extern crate rustc_hash;
10extern crate salsa; 10extern crate salsa;
11 11
12macro_rules! ctry {
13 ($expr:expr) => {
14 match $expr {
15 None => return Ok(None),
16 Some(it) => it,
17 }
18 };
19}
20
12mod arena; 21mod arena;
13mod db; 22mod db;
14mod loc2id; 23mod loc2id;