Drop some unused methods
This commit is contained in:
parent
200bda3daf
commit
7aacf9a197
2 changed files with 5 additions and 49 deletions
|
@ -158,13 +158,6 @@ impl Module {
|
|||
self.with_module_id(def_map.root)
|
||||
}
|
||||
|
||||
/// Finds a child module with the specified name.
|
||||
pub fn child(self, db: &impl DefDatabase, name: &Name) -> Option<Module> {
|
||||
let def_map = db.crate_def_map(self.id.krate);
|
||||
let child_id = def_map[self.id.local_id].children.get(name)?;
|
||||
Some(self.with_module_id(*child_id))
|
||||
}
|
||||
|
||||
/// Iterates over all child modules.
|
||||
pub fn children(self, db: &impl DefDatabase) -> impl Iterator<Item = Module> {
|
||||
let def_map = db.crate_def_map(self.id.krate);
|
||||
|
@ -238,7 +231,7 @@ impl Module {
|
|||
def_map[self.id.local_id].impls.iter().copied().map(ImplBlock::from).collect()
|
||||
}
|
||||
|
||||
fn with_module_id(self, module_id: LocalModuleId) -> Module {
|
||||
pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
|
||||
Module::new(self.krate(), module_id)
|
||||
}
|
||||
}
|
||||
|
@ -303,23 +296,10 @@ impl Struct {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
|
||||
db.struct_data(self.id.into())
|
||||
.variant_data
|
||||
.fields()
|
||||
.iter()
|
||||
.find(|(_id, data)| data.name == *name)
|
||||
.map(|(id, _)| StructField { parent: self.into(), id })
|
||||
}
|
||||
|
||||
pub fn ty(self, db: &impl HirDatabase) -> Type {
|
||||
Type::from_def(db, self.id.module(db).krate, self.id)
|
||||
}
|
||||
|
||||
pub fn constructor_ty(self, db: &impl HirDatabase) -> Ty {
|
||||
db.value_ty(self.id.into())
|
||||
}
|
||||
|
||||
fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.struct_data(self.id.into()).variant_data.clone()
|
||||
}
|
||||
|
@ -352,15 +332,6 @@ impl Union {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
|
||||
db.union_data(self.id)
|
||||
.variant_data
|
||||
.fields()
|
||||
.iter()
|
||||
.find(|(_id, data)| data.name == *name)
|
||||
.map(|(id, _)| StructField { parent: self.into(), id })
|
||||
}
|
||||
|
||||
fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.union_data(self.id).variant_data.clone()
|
||||
}
|
||||
|
@ -392,11 +363,6 @@ impl Enum {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn variant(self, db: &impl DefDatabase, name: &Name) -> Option<EnumVariant> {
|
||||
let id = db.enum_data(self.id).variant(name)?;
|
||||
Some(EnumVariant { parent: self, id })
|
||||
}
|
||||
|
||||
pub fn ty(self, db: &impl HirDatabase) -> Type {
|
||||
Type::from_def(db, self.id.module(db).krate, self.id)
|
||||
}
|
||||
|
@ -428,14 +394,6 @@ impl EnumVariant {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
|
||||
self.variant_data(db)
|
||||
.fields()
|
||||
.iter()
|
||||
.find(|(_id, data)| data.name == *name)
|
||||
.map(|(id, _)| StructField { parent: self.into(), id })
|
||||
}
|
||||
|
||||
pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.enum_data(self.parent.id).variants[self.id].variant_data.clone()
|
||||
}
|
||||
|
@ -561,10 +519,6 @@ impl Function {
|
|||
db.body(self.id.into())
|
||||
}
|
||||
|
||||
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
||||
db.value_ty(self.id.into())
|
||||
}
|
||||
|
||||
pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||
db.infer(self.id.into())
|
||||
}
|
||||
|
|
|
@ -216,8 +216,10 @@ impl Module {
|
|||
}
|
||||
}?;
|
||||
|
||||
let child_name = src.value.name()?;
|
||||
parent_module.child(db, &child_name.as_name())
|
||||
let child_name = src.value.name()?.as_name();
|
||||
let def_map = db.crate_def_map(parent_module.id.krate);
|
||||
let child_id = def_map[parent_module.id.local_id].children.get(&child_name)?;
|
||||
Some(parent_module.with_module_id(*child_id))
|
||||
}
|
||||
|
||||
pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Option<Self> {
|
||||
|
|
Loading…
Add table
Reference in a new issue