aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/path_resolution.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-04 12:45:40 +0000
committerGitHub <[email protected]>2021-02-04 12:45:40 +0000
commit1bae5509ad64a560c4597a021ab467ba063d12c0 (patch)
treec1a3bbed8832b554c6991802f728d99ea6ced088 /crates/hir_def/src/nameres/path_resolution.rs
parent01bc1fdff8b04d373e794af29b18243eb9d15e34 (diff)
parent26a2a2433c7bae1533d07a38a6003e6f40fa97d9 (diff)
Merge #7554
7554: Don't keep the parent DefMap alive via Arc r=jonas-schievink a=jonas-schievink This seems like it could easily leak a lot of memory since we don't currently run GC bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/path_resolution.rs')
-rw-r--r--crates/hir_def/src/nameres/path_resolution.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs
index ecf75c777..2a3ac5d7b 100644
--- a/crates/hir_def/src/nameres/path_resolution.rs
+++ b/crates/hir_def/src/nameres/path_resolution.rs
@@ -110,6 +110,7 @@ impl DefMap {
110 let mut result = ResolvePathResult::empty(ReachedFixedPoint::No); 110 let mut result = ResolvePathResult::empty(ReachedFixedPoint::No);
111 result.segment_index = Some(usize::max_value()); 111 result.segment_index = Some(usize::max_value());
112 112
113 let mut arc;
113 let mut current_map = self; 114 let mut current_map = self;
114 loop { 115 loop {
115 let new = current_map.resolve_path_fp_with_macro_single( 116 let new = current_map.resolve_path_fp_with_macro_single(
@@ -131,8 +132,9 @@ impl DefMap {
131 132
132 match &current_map.block { 133 match &current_map.block {
133 Some(block) => { 134 Some(block) => {
134 current_map = &block.parent; 135 original_module = block.parent.local_id;
135 original_module = block.parent_module; 136 arc = block.parent.def_map(db);
137 current_map = &*arc;
136 } 138 }
137 None => return result, 139 None => return result,
138 } 140 }
@@ -152,7 +154,7 @@ impl DefMap {
152 PathKind::DollarCrate(krate) => { 154 PathKind::DollarCrate(krate) => {
153 if krate == self.krate { 155 if krate == self.krate {
154 mark::hit!(macro_dollar_crate_self); 156 mark::hit!(macro_dollar_crate_self);
155 PerNs::types(self.crate_root().into(), Visibility::Public) 157 PerNs::types(self.crate_root(db).into(), Visibility::Public)
156 } else { 158 } else {
157 let def_map = db.crate_def_map(krate); 159 let def_map = db.crate_def_map(krate);
158 let module = def_map.module_id(def_map.root); 160 let module = def_map.module_id(def_map.root);
@@ -160,7 +162,7 @@ impl DefMap {
160 PerNs::types(module.into(), Visibility::Public) 162 PerNs::types(module.into(), Visibility::Public)
161 } 163 }
162 } 164 }
163 PathKind::Crate => PerNs::types(self.crate_root().into(), Visibility::Public), 165 PathKind::Crate => PerNs::types(self.crate_root(db).into(), Visibility::Public),
164 // plain import or absolute path in 2015: crate-relative with 166 // plain import or absolute path in 2015: crate-relative with
165 // fallback to extern prelude (with the simplification in 167 // fallback to extern prelude (with the simplification in
166 // rust-lang/rust#57745) 168 // rust-lang/rust#57745)
@@ -206,10 +208,10 @@ impl DefMap {
206 segments: path.segments.clone(), 208 segments: path.segments.clone(),
207 }; 209 };
208 log::debug!("`super` path: {} -> {} in parent map", path, new_path); 210 log::debug!("`super` path: {} -> {} in parent map", path, new_path);
209 return block.parent.resolve_path_fp_with_macro( 211 return block.parent.def_map(db).resolve_path_fp_with_macro(
210 db, 212 db,
211 mode, 213 mode,
212 block.parent_module, 214 block.parent.local_id,
213 &new_path, 215 &new_path,
214 shadow, 216 shadow,
215 ); 217 );