aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-25 12:31:48 +0000
committerGitHub <[email protected]>2021-01-25 12:31:48 +0000
commit0a6b2b784618ffbc7775e9a3e3aaf42689bb2962 (patch)
tree2d1d4f47d12daaa510e43de24b117e8e5954fdd2 /crates/hir_def
parent82af033f2fa19d370797b7c6f3a99acd3e47c89e (diff)
parent5ed5a542fb6741b643c07855625cfd1531c10e2e (diff)
Merge #7424
7424: Derive Default on ItemTree r=lnicola a=lnicola Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/item_tree.rs13
-rw-r--r--crates/hir_def/src/item_tree/lower.rs2
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)]
70pub struct ItemTree { 70pub 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 {
43impl Ctx { 43impl 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),