]> git.lizzy.rs Git - rust.git/commitdiff
internal: perpare to remove ModuleData::default
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 12 Jul 2021 17:02:56 +0000 (20:02 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 12 Jul 2021 17:02:56 +0000 (20:02 +0300)
crates/hir_def/src/nameres.rs

index b4bd1d2e213180e16d426d4d25a6117086935a35..c829b6a64ca1a60f7f81d3ed1d508fee2ab19209 100644 (file)
@@ -202,12 +202,7 @@ pub struct ModuleData {
 
 impl Default for ModuleData {
     fn default() -> Self {
-        ModuleData {
-            parent: None,
-            children: FxHashMap::default(),
-            scope: ItemScope::default(),
-            origin: ModuleOrigin::CrateRoot { definition: FileId(!0) },
-        }
+        ModuleData::new(ModuleOrigin::CrateRoot { definition: FileId(!0) })
     }
 }
 
@@ -450,6 +445,15 @@ pub fn diagnostics(&self) -> &[DefDiagnostic] {
 }
 
 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.
     pub fn definition_source(&self, db: &dyn DefDatabase) -> InFile<ModuleSource> {
         self.origin.definition_source(db)