diff options
author | Laurențiu Nicola <[email protected]> | 2021-01-25 12:12:53 +0000 |
---|---|---|
committer | Laurențiu Nicola <[email protected]> | 2021-01-25 12:12:53 +0000 |
commit | 5ed5a542fb6741b643c07855625cfd1531c10e2e (patch) | |
tree | 138f1ae0f094690b890fe194950d9f0f3a6b2ee9 /crates/hir_def | |
parent | a6a5b02f4ca4549bbd150c09aa18ac3c8e18121c (diff) |
Derive Default on ItemTree
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/item_tree.rs | 13 | ||||
-rw-r--r-- | 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 b8d7608e7..1e5c94660 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -66,7 +66,7 @@ impl GenericParamsId { | |||
66 | } | 66 | } |
67 | 67 | ||
68 | /// The item tree of a source file. | 68 | /// The item tree of a source file. |
69 | #[derive(Debug, Eq, PartialEq)] | 69 | #[derive(Debug, Default, Eq, PartialEq)] |
70 | pub struct ItemTree { | 70 | pub struct ItemTree { |
71 | _c: Count<Self>, | 71 | _c: Count<Self>, |
72 | 72 | ||
@@ -82,7 +82,7 @@ impl ItemTree { | |||
82 | let syntax = if let Some(node) = db.parse_or_expand(file_id) { | 82 | let syntax = if let Some(node) = db.parse_or_expand(file_id) { |
83 | node | 83 | node |
84 | } else { | 84 | } else { |
85 | return Arc::new(Self::empty()); | 85 | return Default::default(); |
86 | }; | 86 | }; |
87 | 87 | ||
88 | let hygiene = Hygiene::new(db.upcast(), file_id); | 88 | let hygiene = Hygiene::new(db.upcast(), file_id); |
@@ -118,15 +118,6 @@ impl ItemTree { | |||
118 | Arc::new(item_tree) | 118 | Arc::new(item_tree) |
119 | } | 119 | } |
120 | 120 | ||
121 | fn empty() -> Self { | ||
122 | Self { | ||
123 | _c: Count::new(), | ||
124 | top_level: Default::default(), | ||
125 | attrs: Default::default(), | ||
126 | data: Default::default(), | ||
127 | } | ||
128 | } | ||
129 | |||
130 | fn shrink_to_fit(&mut self) { | 121 | fn shrink_to_fit(&mut self) { |
131 | if let Some(data) = &mut self.data { | 122 | if let Some(data) = &mut self.data { |
132 | let ItemTreeData { | 123 | let ItemTreeData { |
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index ce470fc3b..8a71376b9 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 { | |||
43 | impl Ctx { | 43 | impl Ctx { |
44 | pub(super) fn new(db: &dyn DefDatabase, hygiene: Hygiene, file: HirFileId) -> Self { | 44 | pub(super) fn new(db: &dyn DefDatabase, hygiene: Hygiene, file: HirFileId) -> Self { |
45 | Self { | 45 | Self { |
46 | tree: ItemTree::empty(), | 46 | tree: ItemTree::default(), |
47 | hygiene, | 47 | hygiene, |
48 | file, | 48 | file, |
49 | source_ast_id_map: db.ast_id_map(file), | 49 | source_ast_id_map: db.ast_id_map(file), |