diff options
author | Aleksey Kladov <[email protected]> | 2019-11-24 14:00:10 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-24 14:36:06 +0000 |
commit | 99af523b68d3056c0ee355821b9b8f3c6fb5f504 (patch) | |
tree | af350966c71287e4531fb80897b26699f560a6a6 /crates/ra_hir_def/src | |
parent | 326f066aa21ed2f40f064d0a6c1bdf7d519bfd7b (diff) |
Cleanup
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/per_ns.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 2 |
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 | ||
10 | pub mod db; | 10 | pub mod db; |
11 | |||
11 | pub mod attr; | 12 | pub mod attr; |
12 | pub mod path; | 13 | pub mod path; |
13 | pub mod type_ref; | 14 | pub mod type_ref; |
14 | pub mod builtin_type; | 15 | pub mod builtin_type; |
15 | pub mod adt; | ||
16 | pub mod diagnostics; | 16 | pub mod diagnostics; |
17 | pub mod expr; | 17 | pub mod per_ns; |
18 | pub mod body; | 18 | |
19 | pub mod generics; | 19 | pub mod adt; |
20 | pub mod resolver; | ||
21 | pub mod data; | 20 | pub mod data; |
21 | pub mod generics; | ||
22 | pub mod lang_item; | 22 | pub mod lang_item; |
23 | pub mod docs; | 23 | pub mod docs; |
24 | pub mod per_ns; | 24 | |
25 | pub mod expr; | ||
26 | pub mod body; | ||
27 | pub mod resolver; | ||
25 | 28 | ||
26 | mod trace; | 29 | mod trace; |
27 | mod nameres; | 30 | mod 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)) { |