@@ -1525,7 +1525,7 @@ impl ModCollector<'_, '_> {
15251525 } ;
15261526
15271527 match item {
1528- ModItem :: Mod ( m) => self . collect_module ( & self . item_tree [ m ] , & attrs) ,
1528+ ModItem :: Mod ( m) => self . collect_module ( m , & attrs) ,
15291529 ModItem :: Import ( import_id) => {
15301530 let imports = Import :: from_use (
15311531 db,
@@ -1700,9 +1700,10 @@ impl ModCollector<'_, '_> {
17001700 }
17011701 }
17021702
1703- fn collect_module ( & mut self , module : & Mod , attrs : & Attrs ) {
1703+ fn collect_module ( & mut self , module_id : FileItemTreeId < Mod > , attrs : & Attrs ) {
17041704 let path_attr = attrs. by_key ( "path" ) . string_value ( ) ;
17051705 let is_macro_use = attrs. by_key ( "macro_use" ) . exists ( ) ;
1706+ let module = & self . item_tree [ module_id] ;
17061707 match & module. kind {
17071708 // inline module, just recurse
17081709 ModKind :: Inline { items } => {
@@ -1711,6 +1712,7 @@ impl ModCollector<'_, '_> {
17111712 AstId :: new ( self . file_id ( ) , module. ast_id ) ,
17121713 None ,
17131714 & self . item_tree [ module. visibility ] ,
1715+ module_id,
17141716 ) ;
17151717
17161718 if let Some ( mod_dir) = self . mod_dir . descend_into_definition ( & module. name , path_attr)
@@ -1748,6 +1750,7 @@ impl ModCollector<'_, '_> {
17481750 ast_id,
17491751 Some ( ( file_id, is_mod_rs) ) ,
17501752 & self . item_tree [ module. visibility ] ,
1753+ module_id,
17511754 ) ;
17521755 ModCollector {
17531756 def_collector : self . def_collector ,
@@ -1774,6 +1777,7 @@ impl ModCollector<'_, '_> {
17741777 ast_id,
17751778 None ,
17761779 & self . item_tree [ module. visibility ] ,
1780+ module_id,
17771781 ) ;
17781782 self . def_collector . def_map . diagnostics . push (
17791783 DefDiagnostic :: unresolved_module ( self . module_id , ast_id, candidates) ,
@@ -1790,17 +1794,24 @@ impl ModCollector<'_, '_> {
17901794 declaration : AstId < ast:: Module > ,
17911795 definition : Option < ( FileId , bool ) > ,
17921796 visibility : & crate :: visibility:: RawVisibility ,
1797+ mod_tree_id : FileItemTreeId < Mod > ,
17931798 ) -> LocalModuleId {
17941799 let def_map = & mut self . def_collector . def_map ;
17951800 let vis = def_map
17961801 . resolve_visibility ( self . def_collector . db , self . module_id , visibility)
17971802 . unwrap_or ( Visibility :: Public ) ;
17981803 let modules = & mut def_map. modules ;
17991804 let origin = match definition {
1800- None => ModuleOrigin :: Inline { definition : declaration } ,
1801- Some ( ( definition, is_mod_rs) ) => {
1802- ModuleOrigin :: File { declaration, definition, is_mod_rs }
1803- }
1805+ None => ModuleOrigin :: Inline {
1806+ definition : declaration,
1807+ definition_tree_id : ItemTreeId :: new ( self . tree_id , mod_tree_id) ,
1808+ } ,
1809+ Some ( ( definition, is_mod_rs) ) => ModuleOrigin :: File {
1810+ declaration,
1811+ definition,
1812+ is_mod_rs,
1813+ declaration_tree_id : ItemTreeId :: new ( self . tree_id , mod_tree_id) ,
1814+ } ,
18041815 } ;
18051816
18061817 let res = modules. alloc ( ModuleData :: new ( origin, vis) ) ;
0 commit comments