@@ -1525,7 +1525,7 @@ impl ModCollector<'_, '_> {
1525
1525
} ;
1526
1526
1527
1527
match item {
1528
- ModItem :: Mod ( m) => self . collect_module ( & self . item_tree [ m ] , & attrs) ,
1528
+ ModItem :: Mod ( m) => self . collect_module ( m , & attrs) ,
1529
1529
ModItem :: Import ( import_id) => {
1530
1530
let imports = Import :: from_use (
1531
1531
db,
@@ -1700,9 +1700,10 @@ impl ModCollector<'_, '_> {
1700
1700
}
1701
1701
}
1702
1702
1703
- fn collect_module ( & mut self , module : & Mod , attrs : & Attrs ) {
1703
+ fn collect_module ( & mut self , module_id : FileItemTreeId < Mod > , attrs : & Attrs ) {
1704
1704
let path_attr = attrs. by_key ( "path" ) . string_value ( ) ;
1705
1705
let is_macro_use = attrs. by_key ( "macro_use" ) . exists ( ) ;
1706
+ let module = & self . item_tree [ module_id] ;
1706
1707
match & module. kind {
1707
1708
// inline module, just recurse
1708
1709
ModKind :: Inline { items } => {
@@ -1711,6 +1712,7 @@ impl ModCollector<'_, '_> {
1711
1712
AstId :: new ( self . file_id ( ) , module. ast_id ) ,
1712
1713
None ,
1713
1714
& self . item_tree [ module. visibility ] ,
1715
+ module_id,
1714
1716
) ;
1715
1717
1716
1718
if let Some ( mod_dir) = self . mod_dir . descend_into_definition ( & module. name , path_attr)
@@ -1748,6 +1750,7 @@ impl ModCollector<'_, '_> {
1748
1750
ast_id,
1749
1751
Some ( ( file_id, is_mod_rs) ) ,
1750
1752
& self . item_tree [ module. visibility ] ,
1753
+ module_id,
1751
1754
) ;
1752
1755
ModCollector {
1753
1756
def_collector : self . def_collector ,
@@ -1774,6 +1777,7 @@ impl ModCollector<'_, '_> {
1774
1777
ast_id,
1775
1778
None ,
1776
1779
& self . item_tree [ module. visibility ] ,
1780
+ module_id,
1777
1781
) ;
1778
1782
self . def_collector . def_map . diagnostics . push (
1779
1783
DefDiagnostic :: unresolved_module ( self . module_id , ast_id, candidates) ,
@@ -1790,17 +1794,24 @@ impl ModCollector<'_, '_> {
1790
1794
declaration : AstId < ast:: Module > ,
1791
1795
definition : Option < ( FileId , bool ) > ,
1792
1796
visibility : & crate :: visibility:: RawVisibility ,
1797
+ mod_tree_id : FileItemTreeId < Mod > ,
1793
1798
) -> LocalModuleId {
1794
1799
let def_map = & mut self . def_collector . def_map ;
1795
1800
let vis = def_map
1796
1801
. resolve_visibility ( self . def_collector . db , self . module_id , visibility)
1797
1802
. unwrap_or ( Visibility :: Public ) ;
1798
1803
let modules = & mut def_map. modules ;
1799
1804
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
+ } ,
1804
1815
} ;
1805
1816
1806
1817
let res = modules. alloc ( ModuleData :: new ( origin, vis) ) ;
0 commit comments