Skip to content

Commit d40cf52

Browse files
committed
internal: perpare to remove ModuleData::default
1 parent 107e074 commit d40cf52

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

crates/hir_def/src/nameres.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,7 @@ pub struct ModuleData {
202202

203203
impl Default for ModuleData {
204204
fn default() -> Self {
205-
ModuleData {
206-
parent: None,
207-
children: FxHashMap::default(),
208-
scope: ItemScope::default(),
209-
origin: ModuleOrigin::CrateRoot { definition: FileId(!0) },
210-
}
205+
ModuleData::new(ModuleOrigin::CrateRoot { definition: FileId(!0) })
211206
}
212207
}
213208

@@ -450,6 +445,15 @@ impl DefMap {
450445
}
451446

452447
impl ModuleData {
448+
pub(crate) fn new(origin: ModuleOrigin) -> Self {
449+
ModuleData {
450+
parent: None,
451+
children: FxHashMap::default(),
452+
scope: ItemScope::default(),
453+
origin,
454+
}
455+
}
456+
453457
/// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
454458
pub fn definition_source(&self, db: &dyn DefDatabase) -> InFile<ModuleSource> {
455459
self.origin.definition_source(db)

0 commit comments

Comments
 (0)