From 99af523b68d3056c0ee355821b9b8f3c6fb5f504 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Nov 2019 17:00:10 +0300 Subject: Cleanup --- crates/ra_hir/src/code_model.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/lib.rs | 15 +++++++++------ crates/ra_hir_def/src/nameres.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_hir_def/src/per_ns.rs | 10 +--------- crates/ra_hir_def/src/resolver.rs | 2 +- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 905bb5bcb..b3e2ff1c2 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1037,7 +1037,7 @@ impl From for ScopeDef { .or_else(|| def.take_values()) .map(|module_def_id| ScopeDef::ModuleDef(module_def_id.into())) .or_else(|| { - def.get_macros().map(|macro_def_id| ScopeDef::MacroDef(macro_def_id.into())) + def.take_macros().map(|macro_def_id| ScopeDef::MacroDef(macro_def_id.into())) }) .unwrap_or(ScopeDef::Unknown) } 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 { } fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option { - self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros() + self.crate_def_map.resolve_path(db, self.module.module_id, path).0.take_macros() } } 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 @@ //! actually true. pub mod db; + pub mod attr; pub mod path; pub mod type_ref; pub mod builtin_type; -pub mod adt; pub mod diagnostics; -pub mod expr; -pub mod body; -pub mod generics; -pub mod resolver; +pub mod per_ns; + +pub mod adt; pub mod data; +pub mod generics; pub mod lang_item; pub mod docs; -pub mod per_ns; + +pub mod expr; +pub mod body; +pub mod resolver; mod trace; 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 { pub fn macros<'a>(&'a self) -> impl Iterator + 'a { self.items .iter() - .filter_map(|(name, res)| res.def.get_macros().map(|macro_| (name, macro_))) + .filter_map(|(name, res)| res.def.take_macros().map(|macro_| (name, macro_))) } /// 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 path, ); - if let Some(def) = resolved_res.resolved_def.get_macros() { + if let Some(def) = resolved_res.resolved_def.take_macros() { let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id: *ast_id }); resolved.push((*module_id, call_id, def)); 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 { self.types.is_none() && self.values.is_none() && self.macros.is_none() } - pub fn is_all(&self) -> bool { - self.types.is_some() && self.values.is_some() && self.macros.is_some() - } - pub fn take_types(self) -> Option { self.types } @@ -56,14 +52,10 @@ impl PerNs { self.values } - pub fn get_macros(&self) -> Option { + pub fn take_macros(self) -> Option { self.macros } - pub fn only_macros(&self) -> PerNs { - PerNs { types: None, values: None, macros: self.macros } - } - pub fn or(self, other: PerNs) -> PerNs { PerNs { 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 { pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option { let (item_map, module) = self.module()?; - item_map.resolve_path(db, module, path).0.get_macros() + item_map.resolve_path(db, module, path).0.take_macros() } pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { -- cgit v1.2.3