From: Aleksey Kladov Date: Mon, 12 Jul 2021 17:02:56 +0000 (+0300) Subject: internal: perpare to remove ModuleData::default X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;ds=sidebyside;h=d40cf52e6d105bf807f78bd00b69ecd2cb4826b9;p=rust.git internal: perpare to remove ModuleData::default --- diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index b4bd1d2e213..c829b6a64ca 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs @@ -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 { self.origin.definition_source(db)