aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/source_binder.rs26
1 files changed, 15 insertions, 11 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index fa225a4ed..b2b17d510 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -111,7 +111,10 @@ impl<DB: HirDatabase> SourceBinder<'_, DB> {
111 let def: UnionId = self.to_id(container.with_value(it))?; 111 let def: UnionId = self.to_id(container.with_value(it))?;
112 VariantId::from(def).into() 112 VariantId::from(def).into()
113 }, 113 },
114 // FIXME: handle out-of-line modules here 114 ast::Module(it) => {
115 let def: ModuleId = self.to_id(container.with_value(it))?;
116 def.into()
117 },
115 _ => { continue }, 118 _ => { continue },
116 } 119 }
117 }; 120 };
@@ -162,6 +165,7 @@ macro_rules! to_def_impls {
162} 165}
163 166
164to_def_impls![ 167to_def_impls![
168 (crate::Module, ast::Module),
165 (crate::Struct, ast::StructDef), 169 (crate::Struct, ast::StructDef),
166 (crate::Enum, ast::EnumDef), 170 (crate::Enum, ast::EnumDef),
167 (crate::Union, ast::UnionDef), 171 (crate::Union, ast::UnionDef),
@@ -318,13 +322,13 @@ impl ToDef for ast::TypeParam {
318 } 322 }
319} 323}
320 324
321impl ToDef for ast::Module { 325impl ToId for ast::Module {
322 type Def = Module; 326 type ID = ModuleId;
323 327
324 fn to_def<DB: HirDatabase>( 328 fn to_id<DB: HirDatabase>(
325 sb: &mut SourceBinder<'_, DB>, 329 sb: &mut SourceBinder<'_, DB>,
326 src: InFile<ast::Module>, 330 src: InFile<ast::Module>,
327 ) -> Option<Module> { 331 ) -> Option<ModuleId> {
328 { 332 {
329 let _p = profile("ast::Module::to_def"); 333 let _p = profile("ast::Module::to_def");
330 let parent_declaration = src 334 let parent_declaration = src
@@ -339,17 +343,17 @@ impl ToDef for ast::Module {
339 }); 343 });
340 344
341 let parent_module = match parent_declaration { 345 let parent_module = match parent_declaration {
342 Some(parent_declaration) => sb.to_def(parent_declaration), 346 Some(parent_declaration) => sb.to_id(parent_declaration)?,
343 None => { 347 None => {
344 let file_id = src.file_id.original_file(sb.db); 348 let file_id = src.file_id.original_file(sb.db);
345 sb.to_module_def(file_id) 349 sb.to_module_def(file_id)?.id
346 } 350 }
347 }?; 351 };
348 352
349 let child_name = src.value.name()?.as_name(); 353 let child_name = src.value.name()?.as_name();
350 let def_map = sb.db.crate_def_map(parent_module.id.krate); 354 let def_map = sb.db.crate_def_map(parent_module.krate);
351 let child_id = def_map[parent_module.id.local_id].children.get(&child_name)?; 355 let child_id = *def_map[parent_module.local_id].children.get(&child_name)?;
352 Some(parent_module.with_module_id(*child_id)) 356 Some(ModuleId { krate: parent_module.krate, local_id: child_id })
353 } 357 }
354 } 358 }
355} 359}