]> git.lizzy.rs Git - rust.git/blob - src/test/ui/panic-while-printing.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[rust.git] / src / test / ui / panic-while-printing.rs
1 // run-pass
2 // needs-unwind
3 // ignore-emscripten no subprocess support
4
5 #![feature(internal_output_capture)]
6
7 use std::fmt;
8 use std::fmt::{Display, Formatter};
9 use std::io::set_output_capture;
10 use std::sync::{Arc, Mutex};
11
12 pub struct A;
13
14 impl Display for A {
15     fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
16         panic!();
17     }
18 }
19
20 fn main() {
21     set_output_capture(Some(Arc::new(Mutex::new(Vec::new()))));
22     assert!(std::panic::catch_unwind(|| {
23         eprintln!("{}", A);
24     })
25     .is_err());
26 }