aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-03-23 11:34:56 +0000
committerKirill Bulatov <[email protected]>2020-03-24 08:43:22 +0000
commit944f28fe5bf2b8e4316cc67bf5f824333fc4f180 (patch)
tree8deb8e01871b17968611832b795abcd1c3fd24e8 /crates/ra_hir/src
parentd5e11b33a36755b139367e1f91a52f5ec27193f6 (diff)
Use more generic public api
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs21
-rw-r--r--crates/ra_hir/src/from_id.rs21
2 files changed, 21 insertions, 21 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 9e4aa6022..c5cfd875f 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -143,17 +143,6 @@ impl ModuleDef {
143 } 143 }
144} 144}
145 145
146impl From<ModuleDef> for ItemInNs {
147 fn from(module_def: ModuleDef) -> Self {
148 match module_def {
149 ModuleDef::Static(_) | ModuleDef::Const(_) | ModuleDef::Function(_) => {
150 ItemInNs::Values(module_def.into())
151 }
152 _ => ItemInNs::Types(module_def.into()),
153 }
154 }
155}
156
157pub use hir_def::{ 146pub use hir_def::{
158 attr::Attrs, item_scope::ItemInNs, visibility::Visibility, AssocItemId, AssocItemLoc, 147 attr::Attrs, item_scope::ItemInNs, visibility::Visibility, AssocItemId, AssocItemLoc,
159}; 148};
@@ -290,9 +279,9 @@ impl Module {
290 pub fn find_use_path( 279 pub fn find_use_path(
291 self, 280 self,
292 db: &dyn DefDatabase, 281 db: &dyn DefDatabase,
293 item: ItemInNs, 282 item: impl Into<ItemInNs>,
294 ) -> Option<hir_def::path::ModPath> { 283 ) -> Option<hir_def::path::ModPath> {
295 hir_def::find_path::find_path(db, item, self.into()) 284 hir_def::find_path::find_path(db, item.into(), self.into())
296 } 285 }
297} 286}
298 287
@@ -764,12 +753,6 @@ impl MacroDef {
764 } 753 }
765} 754}
766 755
767impl From<MacroDef> for ItemInNs {
768 fn from(macro_def: MacroDef) -> Self {
769 ItemInNs::Macros(macro_def.into())
770 }
771}
772
773/// Invariant: `inner.as_assoc_item(db).is_some()` 756/// Invariant: `inner.as_assoc_item(db).is_some()`
774/// We do not actively enforce this invariant. 757/// We do not actively enforce this invariant.
775#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] 758#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs
index c179b13c6..62fb52e72 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/ra_hir/src/from_id.rs
@@ -9,8 +9,8 @@ use hir_def::{
9}; 9};
10 10
11use crate::{ 11use crate::{
12 Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, GenericDef, Local, ModuleDef, StructField, 12 code_model::ItemInNs, Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, GenericDef, Local,
13 VariantDef, 13 MacroDef, ModuleDef, StructField, VariantDef,
14}; 14};
15 15
16macro_rules! from_id { 16macro_rules! from_id {
@@ -228,3 +228,20 @@ impl From<(DefWithBodyId, PatId)> for Local {
228 Local { parent, pat_id } 228 Local { parent, pat_id }
229 } 229 }
230} 230}
231
232impl From<MacroDef> for ItemInNs {
233 fn from(macro_def: MacroDef) -> Self {
234 ItemInNs::Macros(macro_def.into())
235 }
236}
237
238impl From<ModuleDef> for ItemInNs {
239 fn from(module_def: ModuleDef) -> Self {
240 match module_def {
241 ModuleDef::Static(_) | ModuleDef::Const(_) | ModuleDef::Function(_) => {
242 ItemInNs::Values(module_def.into())
243 }
244 _ => ItemInNs::Types(module_def.into()),
245 }
246 }
247}