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