aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-25 18:14:41 +0000
committerAleksey Kladov <[email protected]>2019-01-25 18:14:41 +0000
commitf0c6a040bd5f739de8462a1bec523181bad63d56 (patch)
treea94b037fb6bcabebc8f19283b8e721489d0d7fc1
parent50a7598773eaa57379d81c3d917ab4c84d867a51 (diff)
remove dead code
-rw-r--r--crates/ra_hir/src/module_tree.rs25
1 files changed, 5 insertions, 20 deletions
diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs
index c00834c4c..d5ad9decb 100644
--- a/crates/ra_hir/src/module_tree.rs
+++ b/crates/ra_hir/src/module_tree.rs
@@ -1,6 +1,5 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use rustc_hash::{FxHashMap, FxHashSet};
4use arrayvec::ArrayVec; 3use arrayvec::ArrayVec;
5use relative_path::RelativePathBuf; 4use relative_path::RelativePathBuf;
6use ra_db::{FileId, SourceRoot, CrateId}; 5use ra_db::{FileId, SourceRoot, CrateId};
@@ -147,28 +146,21 @@ impl ModuleTree {
147 let file_id = crate_graph.crate_root(crate_id); 146 let file_id = crate_graph.crate_root(crate_id);
148 let source_root_id = db.file_source_root(file_id); 147 let source_root_id = db.file_source_root(file_id);
149 148
150 let mut roots = FxHashMap::default();
151 let mut visited = FxHashSet::default();
152
153 let source_root = db.source_root(source_root_id); 149 let source_root = db.source_root(source_root_id);
154 let source = SourceItemId { 150 let source = SourceItemId {
155 file_id: file_id.into(), 151 file_id: file_id.into(),
156 item_id: None, 152 item_id: None,
157 }; 153 };
158 let module_id = self.init_subtree(db, &source_root, &mut visited, &mut roots, None, source); 154 self.init_subtree(db, &source_root, None, source);
159 roots.insert(file_id, module_id);
160 } 155 }
161 156
162 fn init_subtree( 157 fn init_subtree(
163 &mut self, 158 &mut self,
164 db: &impl HirDatabase, 159 db: &impl HirDatabase,
165 source_root: &SourceRoot, 160 source_root: &SourceRoot,
166 visited: &mut FxHashSet<SourceItemId>,
167 roots: &mut FxHashMap<FileId, ModuleId>,
168 parent: Option<LinkId>, 161 parent: Option<LinkId>,
169 source: SourceItemId, 162 source: SourceItemId,
170 ) -> ModuleId { 163 ) -> ModuleId {
171 visited.insert(source);
172 let id = self.alloc_mod(ModuleData { 164 let id = self.alloc_mod(ModuleData {
173 source, 165 source,
174 parent, 166 parent,
@@ -187,28 +179,21 @@ impl ModuleTree {
187 let (points_to, problem) = resolve_submodule(db, source.file_id, &sub.name); 179 let (points_to, problem) = resolve_submodule(db, source.file_id, &sub.name);
188 let points_to = points_to 180 let points_to = points_to
189 .into_iter() 181 .into_iter()
190 .map(|file_id| match roots.remove(&file_id) { 182 .map(|file_id| {
191 Some(module_id) => { 183 self.init_subtree(
192 self.mods[module_id].parent = Some(link);
193 module_id
194 }
195 None => self.init_subtree(
196 db, 184 db,
197 source_root, 185 source_root,
198 visited,
199 roots,
200 Some(link), 186 Some(link),
201 SourceItemId { 187 SourceItemId {
202 file_id: file_id.into(), 188 file_id: file_id.into(),
203 item_id: None, 189 item_id: None,
204 }, 190 },
205 ), 191 )
206 }) 192 })
207 .collect::<Vec<_>>(); 193 .collect::<Vec<_>>();
208 (points_to, problem) 194 (points_to, problem)
209 } else { 195 } else {
210 let points_to = 196 let points_to = self.init_subtree(db, source_root, Some(link), sub.source);
211 self.init_subtree(db, source_root, visited, roots, Some(link), sub.source);
212 (vec![points_to], None) 197 (vec![points_to], None)
213 }; 198 };
214 199