aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/from_source.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-03 21:34:50 +0000
committerGitHub <[email protected]>2019-11-03 21:34:50 +0000
commit4fd742d6bc23e2f61d0980e15234f09d7e715b76 (patch)
treec37d38f9313f54ea71580f6bd005f554388a57ab /crates/ra_hir/src/from_source.rs
parentf9f1effd011b906903891c09f1cb6b2a42f73e95 (diff)
parent8922a44395482896fec0c0a47a7fac4612112d45 (diff)
Merge #2163
2163: Move CrateDefMap to hir_def r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/from_source.rs')
-rw-r--r--crates/ra_hir/src/from_source.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index a9de01455..9899bdbbc 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -149,14 +149,20 @@ impl Module {
149 ModuleSource::SourceFile(_) => None, 149 ModuleSource::SourceFile(_) => None,
150 }; 150 };
151 151
152 db.relevant_crates(src.file_id.original_file(db)) 152 db.relevant_crates(src.file_id.original_file(db)).iter().find_map(|&crate_id| {
153 .iter() 153 let def_map = db.crate_def_map(crate_id);
154 .map(|&crate_id| Crate { crate_id }) 154
155 .find_map(|krate| { 155 let (module_id, _module_data) =
156 let def_map = db.crate_def_map(krate); 156 def_map.modules.iter().find(|(_module_id, module_data)| {
157 let module_id = def_map.find_module_by_source(src.file_id, decl_id)?; 157 if decl_id.is_some() {
158 Some(Module::new(krate, module_id)) 158 module_data.declaration == decl_id
159 }) 159 } else {
160 module_data.definition.map(|it| it.into()) == Some(src.file_id)
161 }
162 })?;
163
164 Some(Module::new(Crate { crate_id }, module_id))
165 })
160 } 166 }
161} 167}
162 168