From ccbce1d3b2b9f74619d19c6d3377d20dd06e0050 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 3 Nov 2020 20:49:02 +0100 Subject: [PATCH] Update tests for updated set_panic. --- src/test/ui/panic-while-printing.rs | 11 ++++----- src/test/ui/threads-sendsync/task-stderr.rs | 26 ++++++--------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/test/ui/panic-while-printing.rs b/src/test/ui/panic-while-printing.rs index 21fc12759f87..555b90fbd19e 100644 --- a/src/test/ui/panic-while-printing.rs +++ b/src/test/ui/panic-while-printing.rs @@ -5,7 +5,8 @@ use std::fmt; use std::fmt::{Display, Formatter}; -use std::io::{self, set_panic, LocalOutput, Write}; +use std::io::{self, set_panic, Write}; +use std::sync::{Arc, Mutex}; pub struct A; @@ -16,6 +17,7 @@ impl Display for A { } struct Sink; + impl Write for Sink { fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) @@ -24,14 +26,9 @@ impl Write for Sink { Ok(()) } } -impl LocalOutput for Sink { - fn clone_box(&self) -> Box { - Box::new(Sink) - } -} fn main() { - set_panic(Some(Box::new(Sink))); + set_panic(Some(Arc::new(Mutex::new(Sink)))); assert!(std::panic::catch_unwind(|| { eprintln!("{}", A); }) diff --git a/src/test/ui/threads-sendsync/task-stderr.rs b/src/test/ui/threads-sendsync/task-stderr.rs index bc4bedac196e..8bd78158b54b 100644 --- a/src/test/ui/threads-sendsync/task-stderr.rs +++ b/src/test/ui/threads-sendsync/task-stderr.rs @@ -1,33 +1,21 @@ // run-pass // ignore-emscripten no threads support -#![feature(box_syntax, set_stdio)] +#![feature(set_stdio)] -use std::io::prelude::*; use std::io; use std::str; use std::sync::{Arc, Mutex}; use std::thread; -struct Sink(Arc>>); -impl Write for Sink { - fn write(&mut self, data: &[u8]) -> io::Result { - Write::write(&mut *self.0.lock().unwrap(), data) - } - fn flush(&mut self) -> io::Result<()> { Ok(()) } -} -impl io::LocalOutput for Sink { - fn clone_box(&self) -> Box { - Box::new(Sink(self.0.clone())) - } -} - fn main() { let data = Arc::new(Mutex::new(Vec::new())); - let sink = Sink(data.clone()); - let res = thread::Builder::new().spawn(move|| -> () { - io::set_panic(Some(Box::new(sink))); - panic!("Hello, world!") + let res = thread::Builder::new().spawn({ + let data = data.clone(); + move || { + io::set_panic(Some(data)); + panic!("Hello, world!") + } }).unwrap().join(); assert!(res.is_err());