aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/body.rs2
-rw-r--r--crates/ra_hir_def/src/lib.rs15
-rw-r--r--crates/ra_hir_def/src/nameres.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs2
-rw-r--r--crates/ra_hir_def/src/per_ns.rs10
-rw-r--r--crates/ra_hir_def/src/resolver.rs2
6 files changed, 14 insertions, 19 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index 1589085b5..c06997cf1 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -82,7 +82,7 @@ impl Expander {
82 } 82 }
83 83
84 fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { 84 fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
85 self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros() 85 self.crate_def_map.resolve_path(db, self.module.module_id, path).0.take_macros()
86 } 86 }
87} 87}
88 88
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index f60feb5fa..f63c3dd64 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -8,20 +8,23 @@
8//! actually true. 8//! actually true.
9 9
10pub mod db; 10pub mod db;
11
11pub mod attr; 12pub mod attr;
12pub mod path; 13pub mod path;
13pub mod type_ref; 14pub mod type_ref;
14pub mod builtin_type; 15pub mod builtin_type;
15pub mod adt;
16pub mod diagnostics; 16pub mod diagnostics;
17pub mod expr; 17pub mod per_ns;
18pub mod body; 18
19pub mod generics; 19pub mod adt;
20pub mod resolver;
21pub mod data; 20pub mod data;
21pub mod generics;
22pub mod lang_item; 22pub mod lang_item;
23pub mod docs; 23pub mod docs;
24pub mod per_ns; 24
25pub mod expr;
26pub mod body;
27pub mod resolver;
25 28
26mod trace; 29mod trace;
27mod nameres; 30mod nameres;
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index f6cf59c5f..5919771b0 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -169,7 +169,7 @@ impl ModuleScope {
169 pub fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a { 169 pub fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a {
170 self.items 170 self.items
171 .iter() 171 .iter()
172 .filter_map(|(name, res)| res.def.get_macros().map(|macro_| (name, macro_))) 172 .filter_map(|(name, res)| res.def.take_macros().map(|macro_| (name, macro_)))
173 } 173 }
174 174
175 /// Iterate over all legacy textual scoped macros visable at the end of the module 175 /// Iterate over all legacy textual scoped macros visable at the end of the module
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 7a5f90327..df01a20e1 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -476,7 +476,7 @@ where
476 path, 476 path,
477 ); 477 );
478 478
479 if let Some(def) = resolved_res.resolved_def.get_macros() { 479 if let Some(def) = resolved_res.resolved_def.take_macros() {
480 let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id: *ast_id }); 480 let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id: *ast_id });
481 resolved.push((*module_id, call_id, def)); 481 resolved.push((*module_id, call_id, def));
482 res = ReachedFixedPoint::No; 482 res = ReachedFixedPoint::No;
diff --git a/crates/ra_hir_def/src/per_ns.rs b/crates/ra_hir_def/src/per_ns.rs
index 717ed1ef9..06ef6c9fc 100644
--- a/crates/ra_hir_def/src/per_ns.rs
+++ b/crates/ra_hir_def/src/per_ns.rs
@@ -44,10 +44,6 @@ impl PerNs {
44 self.types.is_none() && self.values.is_none() && self.macros.is_none() 44 self.types.is_none() && self.values.is_none() && self.macros.is_none()
45 } 45 }
46 46
47 pub fn is_all(&self) -> bool {
48 self.types.is_some() && self.values.is_some() && self.macros.is_some()
49 }
50
51 pub fn take_types(self) -> Option<ModuleDefId> { 47 pub fn take_types(self) -> Option<ModuleDefId> {
52 self.types 48 self.types
53 } 49 }
@@ -56,14 +52,10 @@ impl PerNs {
56 self.values 52 self.values
57 } 53 }
58 54
59 pub fn get_macros(&self) -> Option<MacroDefId> { 55 pub fn take_macros(self) -> Option<MacroDefId> {
60 self.macros 56 self.macros
61 } 57 }
62 58
63 pub fn only_macros(&self) -> PerNs {
64 PerNs { types: None, values: None, macros: self.macros }
65 }
66
67 pub fn or(self, other: PerNs) -> PerNs { 59 pub fn or(self, other: PerNs) -> PerNs {
68 PerNs { 60 PerNs {
69 types: self.types.or(other.types), 61 types: self.types.or(other.types),
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 4ff0a091b..7182b8a4d 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -308,7 +308,7 @@ impl Resolver {
308 308
309 pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { 309 pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
310 let (item_map, module) = self.module()?; 310 let (item_map, module) = self.module()?;
311 item_map.resolve_path(db, module, path).0.get_macros() 311 item_map.resolve_path(db, module, path).0.take_macros()
312 } 312 }
313 313
314 pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { 314 pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {