]> git.proxmox.com Git - rustc.git/blame - src/test/ui/panic-while-printing.rs
New upstream version 1.50.0+dfsg1
[rustc.git] / src / test / ui / panic-while-printing.rs
CommitLineData
ba9703b0
XL
1// run-pass
2// ignore-emscripten no subprocess support
3
fc512014 4#![feature(internal_output_capture)]
ba9703b0
XL
5
6use std::fmt;
7use std::fmt::{Display, Formatter};
fc512014
XL
8use std::io::set_output_capture;
9use std::sync::{Arc, Mutex};
ba9703b0
XL
10
11pub struct A;
12
13impl Display for A {
14 fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
15 panic!();
16 }
17}
18
19fn main() {
fc512014 20 set_output_capture(Some(Arc::new(Mutex::new(Vec::new()))));
ba9703b0
XL
21 assert!(std::panic::catch_unwind(|| {
22 eprintln!("{}", A);
23 })
24 .is_err());
25}