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