@@ -111,7 +111,10 @@ impl<DB: HirDatabase> SourceBinder<'_, DB> {
111111 let def: UnionId = self . to_id( container. with_value( it) ) ?;
112112 VariantId :: from( def) . into( )
113113 } ,
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+ } ,
115118 _ => { continue } ,
116119 }
117120 } ;
@@ -162,6 +165,7 @@ macro_rules! to_def_impls {
162165}
163166
164167to_def_impls ! [
168+ ( crate :: Module , ast:: Module ) ,
165169 ( crate :: Struct , ast:: StructDef ) ,
166170 ( crate :: Enum , ast:: EnumDef ) ,
167171 ( crate :: Union , ast:: UnionDef ) ,
@@ -318,13 +322,13 @@ impl ToDef for ast::TypeParam {
318322 }
319323}
320324
321- impl ToDef for ast:: Module {
322- type Def = Module ;
325+ impl ToId for ast:: Module {
326+ type ID = ModuleId ;
323327
324- fn to_def < DB : HirDatabase > (
328+ fn to_id < DB : HirDatabase > (
325329 sb : & mut SourceBinder < ' _ , DB > ,
326330 src : InFile < ast:: Module > ,
327- ) -> Option < Module > {
331+ ) -> Option < ModuleId > {
328332 {
329333 let _p = profile ( "ast::Module::to_def" ) ;
330334 let parent_declaration = src
@@ -339,17 +343,17 @@ impl ToDef for ast::Module {
339343 } ) ;
340344
341345 let parent_module = match parent_declaration {
342- Some ( parent_declaration) => sb. to_def ( parent_declaration) ,
346+ Some ( parent_declaration) => sb. to_id ( parent_declaration) ? ,
343347 None => {
344348 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
346350 }
347- } ? ;
351+ } ;
348352
349353 let child_name = src. value . name ( ) ?. as_name ( ) ;
350- let def_map = sb. db . crate_def_map ( parent_module. id . krate ) ;
351- let child_id = def_map[ parent_module. id . local_id ] . children . get ( & child_name) ?;
352- Some ( parent_module. with_module_id ( * child_id) )
354+ let def_map = sb. db . crate_def_map ( parent_module. krate ) ;
355+ let child_id = * def_map[ parent_module. local_id ] . children . get ( & child_name) ?;
356+ Some ( ModuleId { krate : parent_module. krate , local_id : child_id } )
353357 }
354358 }
355359}
0 commit comments