Rollup merge of #51973 - estk:master, r=abonander
Make Stdio handle UnwindSafe Closes #51863 This is my first compiler PR. Thanks Niko for the mentor help! r? @nikomatsakis
This commit is contained in:
@@ -712,9 +712,31 @@ pub fn _eprint(args: fmt::Arguments) {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use panic::{UnwindSafe, RefUnwindSafe};
|
||||||
use thread;
|
use thread;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stdout_unwind_safe() {
|
||||||
|
assert_unwind_safe::<Stdout>();
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn stdoutlock_unwind_safe() {
|
||||||
|
assert_unwind_safe::<StdoutLock>();
|
||||||
|
assert_unwind_safe::<StdoutLock<'static>>();
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn stderr_unwind_safe() {
|
||||||
|
assert_unwind_safe::<Stderr>();
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn stderrlock_unwind_safe() {
|
||||||
|
assert_unwind_safe::<StderrLock>();
|
||||||
|
assert_unwind_safe::<StderrLock<'static>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assert_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||||
fn panic_doesnt_poison() {
|
fn panic_doesnt_poison() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use marker;
|
|||||||
use ops::Deref;
|
use ops::Deref;
|
||||||
use sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
|
use sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
|
||||||
use sys::mutex as sys;
|
use sys::mutex as sys;
|
||||||
|
use panic::{UnwindSafe, RefUnwindSafe};
|
||||||
|
|
||||||
/// A re-entrant mutual exclusion
|
/// A re-entrant mutual exclusion
|
||||||
///
|
///
|
||||||
@@ -28,6 +29,9 @@ pub struct ReentrantMutex<T> {
|
|||||||
unsafe impl<T: Send> Send for ReentrantMutex<T> {}
|
unsafe impl<T: Send> Send for ReentrantMutex<T> {}
|
||||||
unsafe impl<T: Send> Sync for ReentrantMutex<T> {}
|
unsafe impl<T: Send> Sync for ReentrantMutex<T> {}
|
||||||
|
|
||||||
|
impl<T> UnwindSafe for ReentrantMutex<T> {}
|
||||||
|
impl<T> RefUnwindSafe for ReentrantMutex<T> {}
|
||||||
|
|
||||||
|
|
||||||
/// An RAII implementation of a "scoped lock" of a mutex. When this structure is
|
/// An RAII implementation of a "scoped lock" of a mutex. When this structure is
|
||||||
/// dropped (falls out of scope), the lock will be unlocked.
|
/// dropped (falls out of scope), the lock will be unlocked.
|
||||||
|
|||||||
Reference in New Issue
Block a user