mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-07-07 21:35:17 +00:00
Work around a rust-analyzer bug (#855)
This commit is contained in:
parent
a6793e783a
commit
d1da99132d
1 changed files with 22 additions and 2 deletions
24
src/loom.rs
24
src/loom.rs
|
@ -160,9 +160,15 @@ pub use std::{thread, thread_local};
|
|||
pub mod cell {
|
||||
pub use std::cell::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct UnsafeCell<T>(core::cell::UnsafeCell<T>);
|
||||
|
||||
// this is not derived because it confuses rust-analyzer ... https://github.com/rust-lang/rust-analyzer/issues/19755
|
||||
impl<T: std::fmt::Debug> std::fmt::Debug for UnsafeCell<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_tuple("UnsafeCell").field(&self.0).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> UnsafeCell<T> {
|
||||
pub const fn new(data: T) -> UnsafeCell<T> {
|
||||
UnsafeCell(core::cell::UnsafeCell::new(data))
|
||||
|
@ -216,9 +222,23 @@ pub mod sync {
|
|||
}
|
||||
|
||||
/// A wrapper around parking-lot's `Condvar` to mirror loom's API.
|
||||
#[derive(Default, Debug)]
|
||||
pub struct Condvar(parking_lot::Condvar);
|
||||
|
||||
// this is not derived because it confuses rust-analyzer ... https://github.com/rust-lang/rust-analyzer/issues/19755
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for Condvar {
|
||||
fn default() -> Self {
|
||||
Self(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
// this is not derived because it confuses rust-analyzer ... https://github.com/rust-lang/rust-analyzer/issues/19755
|
||||
impl std::fmt::Debug for Condvar {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_tuple("Condvar").field(&self.0).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Condvar {
|
||||
pub fn wait<'a, T>(&self, mut guard: MutexGuard<'a, T>) -> MutexGuard<'a, T> {
|
||||
self.0.wait(&mut guard);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue