Use more generic public api

This commit is contained in:
Kirill Bulatov 2020-03-23 13:34:56 +02:00
parent d5e11b33a3
commit 944f28fe5b
9 changed files with 58 additions and 47 deletions

View file

@ -143,17 +143,6 @@ impl ModuleDef {
}
}
impl From<ModuleDef> for ItemInNs {
fn from(module_def: ModuleDef) -> Self {
match module_def {
ModuleDef::Static(_) | ModuleDef::Const(_) | ModuleDef::Function(_) => {
ItemInNs::Values(module_def.into())
}
_ => ItemInNs::Types(module_def.into()),
}
}
}
pub use hir_def::{
attr::Attrs, item_scope::ItemInNs, visibility::Visibility, AssocItemId, AssocItemLoc,
};
@ -290,9 +279,9 @@ impl Module {
pub fn find_use_path(
self,
db: &dyn DefDatabase,
item: ItemInNs,
item: impl Into<ItemInNs>,
) -> Option<hir_def::path::ModPath> {
hir_def::find_path::find_path(db, item, self.into())
hir_def::find_path::find_path(db, item.into(), self.into())
}
}
@ -764,12 +753,6 @@ impl MacroDef {
}
}
impl From<MacroDef> for ItemInNs {
fn from(macro_def: MacroDef) -> Self {
ItemInNs::Macros(macro_def.into())
}
}
/// Invariant: `inner.as_assoc_item(db).is_some()`
/// We do not actively enforce this invariant.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]