mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
remove useless test hooks
This commit is contained in:
parent
d30bbfda74
commit
af7a0596f6
1 changed files with 0 additions and 43 deletions
|
@ -1,6 +1,4 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(test)]
|
|
||||||
use parking_lot::Mutex;
|
|
||||||
use salsa::{self, Database};
|
use salsa::{self, Database};
|
||||||
use ra_db::{LocationIntener, BaseDatabase};
|
use ra_db::{LocationIntener, BaseDatabase};
|
||||||
use hir::{self, DefId, DefLoc, FnId, SourceItemId};
|
use hir::{self, DefId, DefLoc, FnId, SourceItemId};
|
||||||
|
@ -11,11 +9,6 @@ use crate::{
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct RootDatabase {
|
pub(crate) struct RootDatabase {
|
||||||
#[cfg(test)]
|
|
||||||
events: Mutex<Option<Vec<salsa::Event<RootDatabase>>>>,
|
|
||||||
#[cfg(not(test))]
|
|
||||||
events: (),
|
|
||||||
|
|
||||||
runtime: salsa::Runtime<RootDatabase>,
|
runtime: salsa::Runtime<RootDatabase>,
|
||||||
id_maps: Arc<IdMaps>,
|
id_maps: Arc<IdMaps>,
|
||||||
}
|
}
|
||||||
|
@ -30,23 +23,11 @@ impl salsa::Database for RootDatabase {
|
||||||
fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> {
|
fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> {
|
||||||
&self.runtime
|
&self.runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
fn salsa_event(&self, event: impl Fn() -> salsa::Event<RootDatabase>) {
|
|
||||||
#[cfg(test)]
|
|
||||||
{
|
|
||||||
let mut events = self.events.lock();
|
|
||||||
if let Some(events) = &mut *events {
|
|
||||||
events.push(event());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RootDatabase {
|
impl Default for RootDatabase {
|
||||||
fn default() -> RootDatabase {
|
fn default() -> RootDatabase {
|
||||||
let mut db = RootDatabase {
|
let mut db = RootDatabase {
|
||||||
events: Default::default(),
|
|
||||||
runtime: salsa::Runtime::default(),
|
runtime: salsa::Runtime::default(),
|
||||||
id_maps: Default::default(),
|
id_maps: Default::default(),
|
||||||
};
|
};
|
||||||
|
@ -63,7 +44,6 @@ impl Default for RootDatabase {
|
||||||
impl salsa::ParallelDatabase for RootDatabase {
|
impl salsa::ParallelDatabase for RootDatabase {
|
||||||
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
|
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
|
||||||
salsa::Snapshot::new(RootDatabase {
|
salsa::Snapshot::new(RootDatabase {
|
||||||
events: Default::default(),
|
|
||||||
runtime: self.runtime.snapshot(self),
|
runtime: self.runtime.snapshot(self),
|
||||||
id_maps: self.id_maps.clone(),
|
id_maps: self.id_maps.clone(),
|
||||||
})
|
})
|
||||||
|
@ -84,29 +64,6 @@ impl AsRef<LocationIntener<hir::SourceItemId, FnId>> for RootDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
impl RootDatabase {
|
|
||||||
pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<RootDatabase>> {
|
|
||||||
*self.events.lock() = Some(Vec::new());
|
|
||||||
f();
|
|
||||||
let events = self.events.lock().take().unwrap();
|
|
||||||
events
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
|
|
||||||
let events = self.log(f);
|
|
||||||
events
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|e| match e.kind {
|
|
||||||
// This pretty horrible, but `Debug` is the only way to inspect
|
|
||||||
// QueryDescriptor at the moment.
|
|
||||||
salsa::EventKind::WillExecute { descriptor } => Some(format!("{:?}", descriptor)),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
salsa::database_storage! {
|
salsa::database_storage! {
|
||||||
pub(crate) struct RootDatabaseStorage for RootDatabase {
|
pub(crate) struct RootDatabaseStorage for RootDatabase {
|
||||||
impl ra_db::FilesDatabase {
|
impl ra_db::FilesDatabase {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue