]> git.lizzy.rs Git - rust.git/commitdiff
Switch to fully dynamically dispatched salsa
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 7 Jul 2020 08:14:48 +0000 (10:14 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 7 Jul 2020 08:14:48 +0000 (10:14 +0200)
This improves compile times quite a bit

15 files changed:
Cargo.lock
crates/ra_db/Cargo.toml
crates/ra_db/src/lib.rs
crates/ra_hir_def/src/data.rs
crates/ra_hir_def/src/test_db.rs
crates/ra_hir_expand/src/test_db.rs
crates/ra_hir_ty/src/db.rs
crates/ra_hir_ty/src/lower.rs
crates/ra_hir_ty/src/test_db.rs
crates/ra_hir_ty/src/tests.rs
crates/ra_hir_ty/src/traits/chalk/tls.rs
crates/ra_ide/src/status.rs
crates/ra_ide_db/src/change.rs
crates/ra_ide_db/src/lib.rs
crates/ra_ide_db/src/symbol_index.rs

index c23fea77bee680da12db5ac53d27c32378020c8c..54a95621a667bf18a31c0dab099539d31e3b9661 100644 (file)
@@ -1490,9 +1490,8 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
 
 [[package]]
 name = "salsa"
-version = "0.14.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4ca1c656054666a642affbbc86ab95ed7541125a89f032483d34ee56c0f5390"
+version = "0.14.3"
+source = "git+https://github.com/nikomatsakis/salsa?branch=dynamic-databases-rfc#fd036a4f154c46253443b3a79b6f4400c40e87b1"
 dependencies = [
  "crossbeam-utils",
  "indexmap",
@@ -1508,8 +1507,7 @@ dependencies = [
 [[package]]
 name = "salsa-macros"
 version = "0.14.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "038a09b6271446f1123f142fe7e5bef6d4687c4cf82e6986be574c2af3745530"
+source = "git+https://github.com/nikomatsakis/salsa?branch=dynamic-databases-rfc#fd036a4f154c46253443b3a79b6f4400c40e87b1"
 dependencies = [
  "heck",
  "proc-macro2",
index 372fb242b10c49980523f58a7b9977b2c3ac78db..b2d481dfb494a61fdedd89767dd75dcded3157c5 100644 (file)
@@ -8,7 +8,7 @@ authors = ["rust-analyzer developers"]
 doctest = false
 
 [dependencies]
-salsa = "0.14.1"
+salsa = { git = "https://github.com/nikomatsakis/salsa", branch = "dynamic-databases-rfc" }
 relative-path = "1.0.0"
 rustc-hash = "1.1.0"
 
index 1ddacc1f6c235eef643867226c0b17ed197ee921..590efffa44c83452e9147124a29126cb03c13268 100644 (file)
@@ -113,7 +113,7 @@ pub trait SourceDatabase: CheckCanceled + FileLoader + std::fmt::Debug {
     fn crate_graph(&self) -> Arc<CrateGraph>;
 }
 
-fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
+fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
     let _p = profile("parse_query").detail(|| format!("{:?}", file_id));
     let text = db.file_text(file_id);
     SourceFile::parse(&*text)
@@ -136,10 +136,7 @@ pub trait SourceDatabaseExt: SourceDatabase {
     fn source_root_crates(&self, id: SourceRootId) -> Arc<FxHashSet<CrateId>>;
 }
 
-fn source_root_crates(
-    db: &(impl SourceDatabaseExt + SourceDatabase),
-    id: SourceRootId,
-) -> Arc<FxHashSet<CrateId>> {
+fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<FxHashSet<CrateId>> {
     let graph = db.crate_graph();
     let res = graph
         .iter()
index 282ade2a3a63e4d28078a68dda024e0d5996e2f1..aa335f1e302dd6d3eb6a54d5c01b1e86684fc3fb 100644 (file)
@@ -31,7 +31,7 @@ pub struct FunctionData {
 }
 
 impl FunctionData {
-    pub(crate) fn fn_data_query(db: &impl DefDatabase, func: FunctionId) -> Arc<FunctionData> {
+    pub(crate) fn fn_data_query(db: &dyn DefDatabase, func: FunctionId) -> Arc<FunctionData> {
         let loc = func.lookup(db);
         let item_tree = db.item_tree(loc.id.file_id);
         let func = &item_tree[loc.id.value];
index 4581d87453b2ee166dea46038a42ebc0ffd3ddd5..339f819b8b5bc42c7bd4ae99a8d14aa99f48625e 100644 (file)
@@ -1,7 +1,7 @@
 //! Database used for testing `hir_def`.
 
 use std::{
-    panic,
+    fmt, panic,
     sync::{Arc, Mutex},
 };
 
     crate::db::InternDatabaseStorage,
     crate::db::DefDatabaseStorage
 )]
-#[derive(Debug, Default)]
+#[derive(Default)]
 pub struct TestDB {
-    runtime: salsa::Runtime<TestDB>,
-    events: Mutex<Option<Vec<salsa::Event<TestDB>>>>,
+    storage: salsa::Storage<TestDB>,
+    events: Mutex<Option<Vec<salsa::Event>>>,
 }
 
 impl Upcast<dyn AstDatabase> for TestDB {
@@ -37,20 +37,20 @@ fn upcast(&self) -> &(dyn DefDatabase + 'static) {
 }
 
 impl salsa::Database for TestDB {
-    fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
-        &self.runtime
-    }
-    fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
-        &mut self.runtime
-    }
-    fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) {
+    fn salsa_event(&self, event: salsa::Event) {
         let mut events = self.events.lock().unwrap();
         if let Some(events) = &mut *events {
-            events.push(event());
+            events.push(event);
         }
     }
 }
 
+impl fmt::Debug for TestDB {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.debug_struct("TestDB").finish()
+    }
+}
+
 impl panic::RefUnwindSafe for TestDB {}
 
 impl FileLoader for TestDB {
@@ -78,7 +78,7 @@ pub fn module_for_file(&self, file_id: FileId) -> crate::ModuleId {
         panic!("Can't find module for file")
     }
 
-    pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<TestDB>> {
+    pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
         *self.events.lock().unwrap() = Some(Vec::new());
         f();
         self.events.lock().unwrap().take().unwrap()
@@ -92,7 +92,7 @@ pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
                 // This pretty horrible, but `Debug` is the only way to inspect
                 // QueryDescriptor at the moment.
                 salsa::EventKind::WillExecute { database_key } => {
-                    Some(format!("{:?}", database_key))
+                    Some(format!("{:?}", database_key.debug(self)))
                 }
                 _ => None,
             })
index 09fc18c360f5b7edb4d3dbf3e6abb2bdfd4aa4c4..332fa556fad5236bbde4cae641568cb604256b52 100644 (file)
@@ -1,7 +1,7 @@
 //! Database used for testing `hir_expand`.
 
 use std::{
-    panic,
+    fmt, panic,
     sync::{Arc, Mutex},
 };
 
     ra_db::SourceDatabaseStorage,
     crate::db::AstDatabaseStorage
 )]
-#[derive(Debug, Default)]
+#[derive(Default)]
 pub struct TestDB {
-    runtime: salsa::Runtime<TestDB>,
-    events: Mutex<Option<Vec<salsa::Event<TestDB>>>>,
+    storage: salsa::Storage<TestDB>,
+    events: Mutex<Option<Vec<salsa::Event>>>,
 }
 
-impl salsa::Database for TestDB {
-    fn salsa_runtime(&self) -> &salsa::Runtime<Self> {
-        &self.runtime
-    }
-
-    fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
-        &mut self.runtime
+impl fmt::Debug for TestDB {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.debug_struct("TestDB").finish()
     }
+}
 
-    fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) {
+impl salsa::Database for TestDB {
+    fn salsa_event(&self, event: salsa::Event) {
         let mut events = self.events.lock().unwrap();
         if let Some(events) = &mut *events {
-            events.push(event());
+            events.push(event);
         }
     }
 }
index dc06c0ee720d704eec2b15de640230ab50de01d1..84afe0484b751e573a25698a7c69b139a5523a1e 100644 (file)
@@ -19,7 +19,6 @@
 use hir_expand::name::Name;
 
 #[salsa::query_group(HirDatabaseStorage)]
-#[salsa::requires(salsa::Database)]
 pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
     #[salsa::invoke(infer_wait)]
     #[salsa::transparent]
index 3dc154e92b1282d21a4b0cfdca00eb99568d0bc7..0fa0f7908c3a55cd15b2a1ed5635a2936c11e96c 100644 (file)
@@ -1216,7 +1216,7 @@ pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<
 }
 
 pub(crate) fn return_type_impl_traits(
-    db: &impl HirDatabase,
+    db: &dyn HirDatabase,
     def: hir_def::FunctionId,
 ) -> Option<Arc<Binders<ReturnTypeImplTraits>>> {
     // FIXME unify with fn_sig_for_fn instead of doing lowering twice, maybe
index fddf0604d10b73a740e2fd512400e18c20bb2836..dc447955f751e42d85de22b52e19474604eabde0 100644 (file)
@@ -1,7 +1,7 @@
 //! Database used for testing `hir`.
 
 use std::{
-    panic,
+    fmt, panic,
     sync::{Arc, Mutex},
 };
 
     hir_def::db::DefDatabaseStorage,
     crate::db::HirDatabaseStorage
 )]
-#[derive(Debug, Default)]
+#[derive(Default)]
 pub struct TestDB {
-    events: Mutex<Option<Vec<salsa::Event<TestDB>>>>,
-    runtime: salsa::Runtime<TestDB>,
+    storage: salsa::Storage<TestDB>,
+    events: Mutex<Option<Vec<salsa::Event>>>,
+}
+impl fmt::Debug for TestDB {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.debug_struct("TestDB").finish()
+    }
 }
 
 impl Upcast<dyn AstDatabase> for TestDB {
@@ -45,18 +50,10 @@ fn upcast(&self) -> &(dyn DefDatabase + 'static) {
 }
 
 impl salsa::Database for TestDB {
-    fn salsa_runtime(&self) -> &salsa::Runtime<TestDB> {
-        &self.runtime
-    }
-
-    fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
-        &mut self.runtime
-    }
-
-    fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) {
+    fn salsa_event(&self, event: salsa::Event) {
         let mut events = self.events.lock().unwrap();
         if let Some(events) = &mut *events {
-            events.push(event());
+            events.push(event);
         }
     }
 }
@@ -64,8 +61,8 @@ fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) {
 impl salsa::ParallelDatabase for TestDB {
     fn snapshot(&self) -> salsa::Snapshot<TestDB> {
         salsa::Snapshot::new(TestDB {
+            storage: self.storage.snapshot(),
             events: Default::default(),
-            runtime: self.runtime.snapshot(self),
         })
     }
 }
@@ -182,7 +179,7 @@ pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>>
 }
 
 impl TestDB {
-    pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<TestDB>> {
+    pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> {
         *self.events.lock().unwrap() = Some(Vec::new());
         f();
         self.events.lock().unwrap().take().unwrap()
@@ -196,7 +193,7 @@ pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
                 // This pretty horrible, but `Debug` is the only way to inspect
                 // QueryDescriptor at the moment.
                 salsa::EventKind::WillExecute { database_key } => {
-                    Some(format!("{:?}", database_key))
+                    Some(format!("{:?}", database_key.debug(self)))
                 }
                 _ => None,
             })
index eeac34d1405af1ff7e7582ec11b974a60ba97e67..69f2d7667eec750bab4bcec3162e58e6da97b736 100644 (file)
@@ -21,7 +21,7 @@
 };
 use hir_expand::{db::AstDatabase, InFile};
 use insta::assert_snapshot;
-use ra_db::{fixture::WithFixture, salsa::Database, FileRange, SourceDatabase};
+use ra_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt};
 use ra_syntax::{
     algo,
     ast::{self, AstNode},
@@ -317,7 +317,7 @@ fn foo() -> i32 {
     "
     .to_string();
 
-    db.query_mut(ra_db::FileTextQuery).set(pos.file_id, Arc::new(new_text));
+    db.set_file_text(pos.file_id, Arc::new(new_text));
 
     {
         let events = db.log_executed(|| {
index 556af70989fe8fe00de104e4e1fb9e78af638c76..e6a9d32116a92b89fc0a7a704679af22039228c2 100644 (file)
@@ -10,7 +10,7 @@
 
 pub use unsafe_tls::{set_current_program, with_current_program};
 
-pub struct DebugContext<'a>(&'a (dyn HirDatabase + 'a));
+pub struct DebugContext<'a>(&'a dyn HirDatabase);
 
 impl DebugContext<'_> {
     pub fn debug_struct_id(
index 45411b357c10c0e41cf7e6664bb02b7bfcc6c816..08e6f69cb302a1d88a3e0abcc24fd44aead9be08 100644 (file)
@@ -2,10 +2,7 @@
 
 use hir::MacroFile;
 use ra_db::{
-    salsa::{
-        debug::{DebugQueryTable, TableEntry},
-        Database,
-    },
+    salsa::debug::{DebugQueryTable, TableEntry},
     FileTextQuery, SourceRootId,
 };
 use ra_ide_db::{
 };
 use ra_prof::{memory_usage, Bytes};
 use ra_syntax::{ast, Parse, SyntaxNode};
+use rustc_hash::FxHashMap;
 
 use crate::FileId;
-use rustc_hash::FxHashMap;
 
 fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
-    db.query(ra_db::ParseQuery).entries::<SyntaxTreeStats>()
+    ra_db::ParseQuery.in_db(db).entries::<SyntaxTreeStats>()
 }
 fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
-    db.query(hir::db::ParseMacroQuery).entries::<SyntaxTreeStats>()
+    hir::db::ParseMacroQuery.in_db(db).entries::<SyntaxTreeStats>()
 }
 
 // Feature: Status
@@ -35,10 +32,10 @@ fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
 // | VS Code | **Rust Analyzer: Status**
 // |===
 pub(crate) fn status(db: &RootDatabase) -> String {
-    let files_stats = db.query(FileTextQuery).entries::<FilesStats>();
+    let files_stats = FileTextQuery.in_db(db).entries::<FilesStats>();
     let syntax_tree_stats = syntax_tree_stats(db);
     let macro_syntax_tree_stats = macro_syntax_tree_stats(db);
-    let symbols_stats = db.query(LibrarySymbolsQuery).entries::<LibrarySymbolsStats>();
+    let symbols_stats = LibrarySymbolsQuery.in_db(db).entries::<LibrarySymbolsStats>();
     format!(
         "{}\n{}\n{}\n{} (macros)\n\n\nmemory:\n{}\ngc {:?} seconds ago",
         files_stats,
index 2504d7a338896f7d6d0cfc28ad54620c28185933..d8da3f949ea4162d6b182feeef2a799555037219 100644 (file)
@@ -147,21 +147,21 @@ pub fn collect_garbage(&mut self) {
 
         let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
 
-        self.query(ra_db::ParseQuery).sweep(sweep);
-        self.query(hir::db::ParseMacroQuery).sweep(sweep);
+        ra_db::ParseQuery.in_db(self).sweep(sweep);
+        hir::db::ParseMacroQuery.in_db(self).sweep(sweep);
 
         // Macros do take significant space, but less then the syntax trees
         // self.query(hir::db::MacroDefQuery).sweep(sweep);
         // self.query(hir::db::MacroArgQuery).sweep(sweep);
         // self.query(hir::db::MacroExpandQuery).sweep(sweep);
 
-        self.query(hir::db::AstIdMapQuery).sweep(sweep);
+        hir::db::AstIdMapQuery.in_db(self).sweep(sweep);
 
-        self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
+        hir::db::BodyWithSourceMapQuery.in_db(self).sweep(sweep);
 
-        self.query(hir::db::ExprScopesQuery).sweep(sweep);
-        self.query(hir::db::InferQueryQuery).sweep(sweep);
-        self.query(hir::db::BodyQuery).sweep(sweep);
+        hir::db::ExprScopesQuery.in_db(self).sweep(sweep);
+        hir::db::InferQueryQuery.in_db(self).sweep(sweep);
+        hir::db::BodyQuery.in_db(self).sweep(sweep);
     }
 
     pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> {
@@ -170,14 +170,14 @@ pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> {
         macro_rules! sweep_each_query {
             ($($q:path)*) => {$(
                 let before = memory_usage().allocated;
-                self.query($q).sweep(sweep);
+                $q.in_db(self).sweep(sweep);
                 let after = memory_usage().allocated;
                 let q: $q = Default::default();
                 let name = format!("{:?}", q);
                 acc.push((name, before - after));
 
                 let before = memory_usage().allocated;
-                self.query($q).sweep(sweep.discard_everything());
+                $q.in_db(self).sweep(sweep.discard_everything());
                 let after = memory_usage().allocated;
                 let q: $q = Default::default();
                 let name = format!("{:?} (deps)", q);
@@ -252,7 +252,7 @@ macro_rules! sweep_each_query {
         // write.
         // We do this after collecting the non-interned queries to correctly attribute memory used
         // by interned data.
-        self.runtime.synthetic_write(Durability::HIGH);
+        self.salsa_runtime_mut().synthetic_write(Durability::HIGH);
 
         sweep_each_query![
             // AstDatabase
index c78071ad6ecddbbc69bc6f4cdfa5d7cf831c2ffd..6900cac73e18ca9a11da5b162bde11ea2db77bf1 100644 (file)
 pub mod source_change;
 mod wasm_shims;
 
-use std::sync::Arc;
+use std::{fmt, sync::Arc};
 
 use hir::db::{AstDatabase, DefDatabase, HirDatabase};
 use ra_db::{
-    salsa::{self, Database, Durability},
+    salsa::{self, Durability},
     Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase,
     Upcast,
 };
     hir::db::DefDatabaseStorage,
     hir::db::HirDatabaseStorage
 )]
-#[derive(Debug)]
 pub struct RootDatabase {
-    runtime: salsa::Runtime<RootDatabase>,
+    storage: salsa::Storage<RootDatabase>,
     pub last_gc: crate::wasm_shims::Instant,
     pub last_gc_check: crate::wasm_shims::Instant,
 }
 
+impl fmt::Debug for RootDatabase {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.debug_struct("RootDatabase").finish()
+    }
+}
+
 impl Upcast<dyn AstDatabase> for RootDatabase {
     fn upcast(&self) -> &(dyn AstDatabase + 'static) {
         &*self
@@ -71,17 +76,11 @@ fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
 }
 
 impl salsa::Database for RootDatabase {
-    fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> {
-        &self.runtime
-    }
-    fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> {
-        &mut self.runtime
-    }
     fn on_propagated_panic(&self) -> ! {
         Canceled::throw()
     }
-    fn salsa_event(&self, event: impl Fn() -> salsa::Event<RootDatabase>) {
-        match event().kind {
+    fn salsa_event(&self, event: salsa::Event) {
+        match event.kind {
             salsa::EventKind::DidValidateMemoizedValue { .. }
             | salsa::EventKind::WillExecute { .. } => {
                 self.check_canceled();
@@ -100,7 +99,7 @@ fn default() -> RootDatabase {
 impl RootDatabase {
     pub fn new(lru_capacity: Option<usize>) -> RootDatabase {
         let mut db = RootDatabase {
-            runtime: salsa::Runtime::default(),
+            storage: salsa::Storage::default(),
             last_gc: crate::wasm_shims::Instant::now(),
             last_gc_check: crate::wasm_shims::Instant::now(),
         };
@@ -113,16 +112,16 @@ pub fn new(lru_capacity: Option<usize>) -> RootDatabase {
 
     pub fn update_lru_capacity(&mut self, lru_capacity: Option<usize>) {
         let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP);
-        self.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity);
-        self.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity);
-        self.query_mut(hir::db::MacroExpandQuery).set_lru_capacity(lru_capacity);
+        ra_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
+        hir::db::ParseMacroQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
+        hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
     }
 }
 
 impl salsa::ParallelDatabase for RootDatabase {
     fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
         salsa::Snapshot::new(RootDatabase {
-            runtime: self.runtime.snapshot(self),
+            storage: self.storage.snapshot(),
             last_gc: self.last_gc,
             last_gc_check: self.last_gc_check,
         })
@@ -134,7 +133,7 @@ pub trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled {
     fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
 }
 
-fn line_index(db: &impl LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
+fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
     let text = db.file_text(file_id);
     Arc::new(LineIndex::new(&*text))
 }
index 5a09e7d1de7b241227db46971e16acb1b6a52cdc..131e2a128d1aec7ad9c91eceed42ec05da232ea4 100644 (file)
@@ -87,7 +87,7 @@ pub fn limit(&mut self, limit: usize) {
 }
 
 #[salsa::query_group(SymbolsDatabaseStorage)]
-pub trait SymbolsDatabase: hir::db::HirDatabase + SourceDatabaseExt + ParallelDatabase {
+pub trait SymbolsDatabase: hir::db::HirDatabase + SourceDatabaseExt {
     fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>;
     fn library_symbols(&self) -> Arc<FxHashMap<SourceRootId, SymbolIndex>>;
     /// The set of "local" (that is, from the current workspace) roots.
@@ -100,9 +100,7 @@ pub trait SymbolsDatabase: hir::db::HirDatabase + SourceDatabaseExt + ParallelDa
     fn library_roots(&self) -> Arc<FxHashSet<SourceRootId>>;
 }
 
-fn library_symbols(
-    db: &(impl SymbolsDatabase + ParallelDatabase),
-) -> Arc<FxHashMap<SourceRootId, SymbolIndex>> {
+fn library_symbols(db: &dyn SymbolsDatabase) -> Arc<FxHashMap<SourceRootId, SymbolIndex>> {
     let _p = profile("library_symbols");
 
     let roots = db.library_roots();
@@ -123,7 +121,7 @@ fn library_symbols(
     Arc::new(res)
 }
 
-fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
+fn file_symbols(db: &dyn SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
     db.check_canceled();
     let parse = db.parse(file_id);