From 5ed5a542fb6741b643c07855625cfd1531c10e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 25 Jan 2021 14:12:53 +0200 Subject: [PATCH] Derive Default on ItemTree --- crates/hir_def/src/item_tree.rs | 13 ++----------- crates/hir_def/src/item_tree/lower.rs | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index b8d7608e7c..1e5c946604 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs @@ -66,7 +66,7 @@ impl GenericParamsId { } /// The item tree of a source file. -#[derive(Debug, Eq, PartialEq)] +#[derive(Debug, Default, Eq, PartialEq)] pub struct ItemTree { _c: Count, @@ -82,7 +82,7 @@ impl ItemTree { let syntax = if let Some(node) = db.parse_or_expand(file_id) { node } else { - return Arc::new(Self::empty()); + return Default::default(); }; let hygiene = Hygiene::new(db.upcast(), file_id); @@ -118,15 +118,6 @@ impl ItemTree { Arc::new(item_tree) } - fn empty() -> Self { - Self { - _c: Count::new(), - top_level: Default::default(), - attrs: Default::default(), - data: Default::default(), - } - } - fn shrink_to_fit(&mut self) { if let Some(data) = &mut self.data { let ItemTreeData { diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index ce470fc3bf..8a71376b99 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -43,7 +43,7 @@ pub(super) struct Ctx { impl Ctx { pub(super) fn new(db: &dyn DefDatabase, hygiene: Hygiene, file: HirFileId) -> Self { Self { - tree: ItemTree::empty(), + tree: ItemTree::default(), hygiene, file, source_ast_id_map: db.ast_id_map(file),