From 4bbc385277bcab509c321b1374f72f1ef19d7750 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Jul 2020 10:14:48 +0200 Subject: Switch to fully dynamically dispatched salsa This improves compile times quite a bit --- crates/ra_hir_expand/src/test_db.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir_expand') diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs index 09fc18c36..332fa556f 100644 --- a/crates/ra_hir_expand/src/test_db.rs +++ b/crates/ra_hir_expand/src/test_db.rs @@ -1,7 +1,7 @@ //! Database used for testing `hir_expand`. use std::{ - panic, + fmt, panic, sync::{Arc, Mutex}, }; @@ -13,25 +13,23 @@ use rustc_hash::FxHashSet; ra_db::SourceDatabaseStorage, crate::db::AstDatabaseStorage )] -#[derive(Debug, Default)] +#[derive(Default)] pub struct TestDB { - runtime: salsa::Runtime, - events: Mutex>>>, + storage: salsa::Storage, + events: Mutex>>, } -impl salsa::Database for TestDB { - fn salsa_runtime(&self) -> &salsa::Runtime { - &self.runtime - } - - fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime { - &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) { +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); } } } -- cgit v1.2.3