Skip to content

Commit ccbce1d

Browse files
committed
Update tests for updated set_panic.
1 parent 72e9660 commit ccbce1d

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

src/test/ui/panic-while-printing.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
use std::fmt;
77
use std::fmt::{Display, Formatter};
8-
use std::io::{self, set_panic, LocalOutput, Write};
8+
use std::io::{self, set_panic, Write};
9+
use std::sync::{Arc, Mutex};
910

1011
pub struct A;
1112

@@ -16,6 +17,7 @@ impl Display for A {
1617
}
1718

1819
struct Sink;
20+
1921
impl Write for Sink {
2022
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
2123
Ok(buf.len())
@@ -24,14 +26,9 @@ impl Write for Sink {
2426
Ok(())
2527
}
2628
}
27-
impl LocalOutput for Sink {
28-
fn clone_box(&self) -> Box<dyn LocalOutput> {
29-
Box::new(Sink)
30-
}
31-
}
3229

3330
fn main() {
34-
set_panic(Some(Box::new(Sink)));
31+
set_panic(Some(Arc::new(Mutex::new(Sink))));
3532
assert!(std::panic::catch_unwind(|| {
3633
eprintln!("{}", A);
3734
})

src/test/ui/threads-sendsync/task-stderr.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
11
// run-pass
22
// ignore-emscripten no threads support
33

4-
#![feature(box_syntax, set_stdio)]
4+
#![feature(set_stdio)]
55

6-
use std::io::prelude::*;
76
use std::io;
87
use std::str;
98
use std::sync::{Arc, Mutex};
109
use std::thread;
1110

12-
struct Sink(Arc<Mutex<Vec<u8>>>);
13-
impl Write for Sink {
14-
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
15-
Write::write(&mut *self.0.lock().unwrap(), data)
16-
}
17-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
18-
}
19-
impl io::LocalOutput for Sink {
20-
fn clone_box(&self) -> Box<dyn io::LocalOutput> {
21-
Box::new(Sink(self.0.clone()))
22-
}
23-
}
24-
2511
fn main() {
2612
let data = Arc::new(Mutex::new(Vec::new()));
27-
let sink = Sink(data.clone());
28-
let res = thread::Builder::new().spawn(move|| -> () {
29-
io::set_panic(Some(Box::new(sink)));
30-
panic!("Hello, world!")
13+
let res = thread::Builder::new().spawn({
14+
let data = data.clone();
15+
move || {
16+
io::set_panic(Some(data));
17+
panic!("Hello, world!")
18+
}
3119
}).unwrap().join();
3220
assert!(res.is_err());
3321

0 commit comments

Comments
 (0)