@@ -133,23 +133,27 @@ pub trait SymbolsDatabase: HirDatabase + SourceDatabase {
133
133
fn library_symbols ( db : & dyn SymbolsDatabase , source_root_id : SourceRootId ) -> Arc < SymbolIndex > {
134
134
let _p = tracing:: info_span!( "library_symbols" ) . entered ( ) ;
135
135
136
- let mut symbol_collector = SymbolCollector :: new ( db) ;
137
-
138
- db. source_root_crates ( source_root_id)
139
- . iter ( )
140
- . flat_map ( |& krate| Crate :: from ( krate) . modules ( db) )
141
- // we specifically avoid calling other SymbolsDatabase queries here, even though they do the same thing,
142
- // as the index for a library is not going to really ever change, and we do not want to store each
143
- // the module or crate indices for those in salsa unless we need to.
144
- . for_each ( |module| symbol_collector. collect ( module) ) ;
145
-
146
- Arc :: new ( SymbolIndex :: new ( symbol_collector. finish ( ) ) )
136
+ // We call this without attaching because this runs in parallel, so we need to attach here.
137
+ salsa:: attach ( db, || {
138
+ let mut symbol_collector = SymbolCollector :: new ( db) ;
139
+
140
+ db. source_root_crates ( source_root_id)
141
+ . iter ( )
142
+ . flat_map ( |& krate| Crate :: from ( krate) . modules ( db) )
143
+ // we specifically avoid calling other SymbolsDatabase queries here, even though they do the same thing,
144
+ // as the index for a library is not going to really ever change, and we do not want to store each
145
+ // the module or crate indices for those in salsa unless we need to.
146
+ . for_each ( |module| symbol_collector. collect ( module) ) ;
147
+
148
+ Arc :: new ( SymbolIndex :: new ( symbol_collector. finish ( ) ) )
149
+ } )
147
150
}
148
151
149
152
fn module_symbols ( db : & dyn SymbolsDatabase , module : Module ) -> Arc < SymbolIndex > {
150
153
let _p = tracing:: info_span!( "module_symbols" ) . entered ( ) ;
151
154
152
- Arc :: new ( SymbolIndex :: new ( SymbolCollector :: new_module ( db, module) ) )
155
+ // We call this without attaching because this runs in parallel, so we need to attach here.
156
+ salsa:: attach ( db, || Arc :: new ( SymbolIndex :: new ( SymbolCollector :: new_module ( db, module) ) ) )
153
157
}
154
158
155
159
pub fn crate_symbols ( db : & dyn SymbolsDatabase , krate : Crate ) -> Box < [ Arc < SymbolIndex > ] > {
0 commit comments