aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-21 17:46:44 +0000
committerGitHub <[email protected]>2021-01-21 17:46:44 +0000
commite76d8c1d9af2a78a16d25f348c1d69c331349c1f (patch)
tree0fddaf6d3c87fce5dac56bd0df655fd58a29c9a8 /crates/hir_def
parentb68d6d6fd58b9f59c9c6202771f1a458a2a14c91 (diff)
parente5c5c0a040e0c74892ea0a36c7fd50e5410879bd (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.rs10
-rw-r--r--crates/hir_def/src/nameres.rs3
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};
23use la_arena::{Arena, Idx, RawIdx}; 23use la_arena::{Arena, Idx, RawIdx};
24use profile::Count;
24use rustc_hash::FxHashMap; 25use rustc_hash::FxHashMap;
25use smallvec::SmallVec; 26use smallvec::SmallVec;
26use syntax::{ast, match_ast}; 27use 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)]
69pub struct ItemTree { 70pub 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;
59use base_db::{CrateId, Edition, FileId}; 59use base_db::{CrateId, Edition, FileId};
60use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; 60use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile};
61use la_arena::Arena; 61use la_arena::Arena;
62use profile::Count;
62use rustc_hash::FxHashMap; 63use rustc_hash::FxHashMap;
63use stdx::format_to; 64use stdx::format_to;
64use syntax::{ast, AstNode}; 65use 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)]
77pub struct DefMap { 78pub 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,