Skip to content

Commit d36393b

Browse files
committed
Use Mutex to avoid issue with conditional locks
1 parent 2428054 commit d36393b

File tree

1 file changed

+3
-4
lines changed
  • compiler/rustc_data_structures/src

1 file changed

+3
-4
lines changed

compiler/rustc_data_structures/src/sync.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
//! [^2] `MTLockRef` is a typedef.
4242
4343
pub use crate::marker::*;
44+
use parking_lot::Mutex;
4445
use std::any::Any;
4546
use std::collections::HashMap;
4647
use std::hash::{BuildHasher, Hash};
@@ -110,13 +111,13 @@ pub use mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode};
110111
/// continuing with unwinding. It's also used for the non-parallel code to ensure error message
111112
/// output match the parallel compiler for testing purposes.
112113
pub struct ParallelGuard {
113-
panic: Lock<Option<Box<dyn Any + std::marker::Send + 'static>>>,
114+
panic: Mutex<Option<Box<dyn Any + std::marker::Send + 'static>>>,
114115
}
115116

116117
impl ParallelGuard {
117118
#[inline]
118119
pub fn new() -> Self {
119-
ParallelGuard { panic: Lock::new(None) }
120+
ParallelGuard { panic: Mutex::new(None) }
120121
}
121122

122123
pub fn run<R>(&self, f: impl FnOnce() -> R) -> Option<R> {
@@ -316,8 +317,6 @@ cfg_if! {
316317
}
317318
}
318319
} else {
319-
use parking_lot::Mutex;
320-
321320
pub use std::marker::Send as Send;
322321
pub use std::marker::Sync as Sync;
323322

0 commit comments

Comments
 (0)