diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-21 17:46:44 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-21 17:46:44 +0000 |
commit | e76d8c1d9af2a78a16d25f348c1d69c331349c1f (patch) | |
tree | 0fddaf6d3c87fce5dac56bd0df655fd58a29c9a8 /crates/hir_def | |
parent | b68d6d6fd58b9f59c9c6202771f1a458a2a14c91 (diff) | |
parent | e5c5c0a040e0c74892ea0a36c7fd50e5410879bd (diff) |
Merge #7378
7378: Include `countme` crate to count important data structures. r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/item_tree.rs | 10 | ||||
-rw-r--r-- | crates/hir_def/src/nameres.rs | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 1226d7d85..b8d7608e7 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -21,6 +21,7 @@ use hir_expand::{ | |||
21 | HirFileId, InFile, | 21 | HirFileId, InFile, |
22 | }; | 22 | }; |
23 | use la_arena::{Arena, Idx, RawIdx}; | 23 | use la_arena::{Arena, Idx, RawIdx}; |
24 | use profile::Count; | ||
24 | use rustc_hash::FxHashMap; | 25 | use rustc_hash::FxHashMap; |
25 | use smallvec::SmallVec; | 26 | use smallvec::SmallVec; |
26 | use syntax::{ast, match_ast}; | 27 | use syntax::{ast, match_ast}; |
@@ -67,6 +68,8 @@ impl GenericParamsId { | |||
67 | /// The item tree of a source file. | 68 | /// The item tree of a source file. |
68 | #[derive(Debug, Eq, PartialEq)] | 69 | #[derive(Debug, Eq, PartialEq)] |
69 | pub struct ItemTree { | 70 | pub struct ItemTree { |
71 | _c: Count<Self>, | ||
72 | |||
70 | top_level: SmallVec<[ModItem; 1]>, | 73 | top_level: SmallVec<[ModItem; 1]>, |
71 | attrs: FxHashMap<AttrOwner, RawAttrs>, | 74 | attrs: FxHashMap<AttrOwner, RawAttrs>, |
72 | 75 | ||
@@ -116,7 +119,12 @@ impl ItemTree { | |||
116 | } | 119 | } |
117 | 120 | ||
118 | fn empty() -> Self { | 121 | fn empty() -> Self { |
119 | Self { top_level: Default::default(), attrs: Default::default(), data: Default::default() } | 122 | Self { |
123 | _c: Count::new(), | ||
124 | top_level: Default::default(), | ||
125 | attrs: Default::default(), | ||
126 | data: Default::default(), | ||
127 | } | ||
120 | } | 128 | } |
121 | 129 | ||
122 | fn shrink_to_fit(&mut self) { | 130 | fn shrink_to_fit(&mut self) { |
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 93931a21a..bd3ea9b8b 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs | |||
@@ -59,6 +59,7 @@ use std::sync::Arc; | |||
59 | use base_db::{CrateId, Edition, FileId}; | 59 | use base_db::{CrateId, Edition, FileId}; |
60 | use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; | 60 | use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; |
61 | use la_arena::Arena; | 61 | use la_arena::Arena; |
62 | use profile::Count; | ||
62 | use rustc_hash::FxHashMap; | 63 | use rustc_hash::FxHashMap; |
63 | use stdx::format_to; | 64 | use stdx::format_to; |
64 | use syntax::{ast, AstNode}; | 65 | use syntax::{ast, AstNode}; |
@@ -75,6 +76,7 @@ use crate::{ | |||
75 | /// Contains all top-level defs from a macro-expanded crate | 76 | /// Contains all top-level defs from a macro-expanded crate |
76 | #[derive(Debug, PartialEq, Eq)] | 77 | #[derive(Debug, PartialEq, Eq)] |
77 | pub struct DefMap { | 78 | pub struct DefMap { |
79 | _c: Count<Self>, | ||
78 | parent: Option<Arc<DefMap>>, | 80 | parent: Option<Arc<DefMap>>, |
79 | root: LocalModuleId, | 81 | root: LocalModuleId, |
80 | modules: Arena<ModuleData>, | 82 | modules: Arena<ModuleData>, |
@@ -215,6 +217,7 @@ impl DefMap { | |||
215 | let mut modules: Arena<ModuleData> = Arena::default(); | 217 | let mut modules: Arena<ModuleData> = Arena::default(); |
216 | let root = modules.alloc(ModuleData::default()); | 218 | let root = modules.alloc(ModuleData::default()); |
217 | DefMap { | 219 | DefMap { |
220 | _c: Count::new(), | ||
218 | parent: None, | 221 | parent: None, |
219 | krate, | 222 | krate, |
220 | edition, | 223 | edition, |