Skip to content

Commit 2138b7b

Browse files
committed
change events to take_salsa_events and clear_salsa_events
1 parent 6212aa9 commit 2138b7b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

crates/ruff_db/src/lib.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ mod tests {
5151
use crate::vfs::{VendoredPathBuf, Vfs};
5252
use crate::{Db, Jar};
5353
use salsa::DebugWithDb;
54+
use std::sync::Arc;
5455

5556
/// Database that can be used for testing.
5657
///
@@ -81,8 +82,23 @@ mod tests {
8182
&self.file_system
8283
}
8384

84-
pub(crate) fn events(&self) -> std::sync::Arc<std::sync::Mutex<Vec<salsa::Event>>> {
85-
self.events.clone()
85+
/// Takes the salsa events that have been emitted.
86+
///
87+
/// ## Panics
88+
/// If there are pending database snapshots.
89+
pub(crate) fn take_salsa_events(&mut self) -> Vec<salsa::Event> {
90+
let inner = Arc::get_mut(&mut self.events)
91+
.expect("expected no pending salsa database snapshots.");
92+
93+
std::mem::take(inner.get_mut().unwrap())
94+
}
95+
96+
/// Clears the emitted salsa events.
97+
///
98+
/// ## Panics
99+
/// If there are pending database snapshots.
100+
pub(crate) fn clear_salsa_events(&mut self) {
101+
self.take_salsa_events();
86102
}
87103

88104
pub(crate) fn file_system_mut(&mut self) -> &mut MemoryFileSystem {

0 commit comments

Comments
 (0)