]> git.lizzy.rs Git - rust.git/blob - src/test/ui/test-attrs/test-panic-while-printing.rs
Rollup merge of #100861 - RalfJung:const-ice, r=oli-obk
[rust.git] / src / test / ui / test-attrs / test-panic-while-printing.rs
1 // compile-flags:--test
2 // run-pass
3 // needs-unwind
4 // ignore-emscripten no subprocess support
5
6 use std::fmt;
7 use std::fmt::{Display, Formatter};
8
9 pub struct A(Vec<u32>);
10
11 impl Display for A {
12     fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result {
13         self.0[0];
14         Ok(())
15     }
16 }
17
18 #[test]
19 fn main() {
20     let result = std::panic::catch_unwind(|| {
21         let a = A(vec![]);
22         eprintln!("{}", a);
23     });
24     assert!(result.is_err());
25 }