internal: perpare to remove ModuleData::default

This commit is contained in:
Aleksey Kladov 2021-07-12 20:02:56 +03:00
parent 107e07458c
commit d40cf52e6d

View file

@ -202,12 +202,7 @@ pub struct ModuleData {
impl Default for ModuleData { impl Default for ModuleData {
fn default() -> Self { fn default() -> Self {
ModuleData { ModuleData::new(ModuleOrigin::CrateRoot { definition: FileId(!0) })
parent: None,
children: FxHashMap::default(),
scope: ItemScope::default(),
origin: ModuleOrigin::CrateRoot { definition: FileId(!0) },
}
} }
} }
@ -450,6 +445,15 @@ impl DefMap {
} }
impl ModuleData { impl ModuleData {
pub(crate) fn new(origin: ModuleOrigin) -> Self {
ModuleData {
parent: None,
children: FxHashMap::default(),
scope: ItemScope::default(),
origin,
}
}
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
pub fn definition_source(&self, db: &dyn DefDatabase) -> InFile<ModuleSource> { pub fn definition_source(&self, db: &dyn DefDatabase) -> InFile<ModuleSource> {
self.origin.definition_source(db) self.origin.definition_source(db)