diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-07-12 20:02:56 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-07-12 20:02:56 +0300 |
| commit | d40cf52e6d105bf807f78bd00b69ecd2cb4826b9 (patch) | |
| tree | e0a5b7e527ee3a0b3099a1b1d9d8c35b9528042d | |
| parent | 107e07458c5db92612ddff3a6a196075161694a0 (diff) | |
internal: perpare to remove ModuleData::default
| -rw-r--r-- | crates/hir_def/src/nameres.rs | 16 |
1 files changed, 10 insertions, 6 deletions
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 @@ impl DefMap { } 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) |
