2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
|
|
|
//@ needs-unwind
|
2020-03-12 20:03:48 +00:00
|
|
|
|
2020-11-03 23:11:14 +00:00
|
|
|
#![feature(internal_output_capture)]
|
2020-03-12 20:03:48 +00:00
|
|
|
|
|
|
|
use std::fmt;
|
|
|
|
use std::fmt::{Display, Formatter};
|
2020-11-03 23:11:14 +00:00
|
|
|
use std::io::set_output_capture;
|
2020-11-03 19:49:02 +00:00
|
|
|
use std::sync::{Arc, Mutex};
|
2020-03-12 20:03:48 +00:00
|
|
|
|
|
|
|
pub struct A;
|
|
|
|
|
|
|
|
impl Display for A {
|
|
|
|
fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2020-11-03 23:11:14 +00:00
|
|
|
set_output_capture(Some(Arc::new(Mutex::new(Vec::new()))));
|
2020-03-12 20:03:48 +00:00
|
|
|
assert!(std::panic::catch_unwind(|| {
|
|
|
|
eprintln!("{}", A);
|
|
|
|
})
|
|
|
|
.is_err());
|
|
|
|
}
|