diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-01 02:45:14 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-07-01 02:45:14 +0500 |
| commit | 9a7db566d7b7bb534c5dc3bcfbd2ddd51d99a8d5 (patch) | |
| tree | 41a15423391873b07894d2abb4c9ae994bfd0340 /tests/ui/panics | |
| parent | 5ca574e85b67cec0a6fc3fddfe398cbe676c9c69 (diff) | |
moved tests
Diffstat (limited to 'tests/ui/panics')
| -rw-r--r-- | tests/ui/panics/panic-during-display-formatting.rs | 25 | ||||
| -rw-r--r-- | tests/ui/panics/panic-handler-closures.rs | 10 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/panics/panic-during-display-formatting.rs b/tests/ui/panics/panic-during-display-formatting.rs new file mode 100644 index 00000000000..6505a69fef7 --- /dev/null +++ b/tests/ui/panics/panic-during-display-formatting.rs @@ -0,0 +1,25 @@ +//@ run-pass +//@ needs-unwind + +#![feature(internal_output_capture)] + +use std::fmt; +use std::fmt::{Display, Formatter}; +use std::io::set_output_capture; +use std::sync::{Arc, Mutex}; + +pub struct A; + +impl Display for A { + fn fmt(&self, _f: &mut Formatter<'_>) -> fmt::Result { + panic!(); + } +} + +fn main() { + set_output_capture(Some(Arc::new(Mutex::new(Vec::new())))); + assert!(std::panic::catch_unwind(|| { + eprintln!("{}", A); + }) + .is_err()); +} diff --git a/tests/ui/panics/panic-handler-closures.rs b/tests/ui/panics/panic-handler-closures.rs new file mode 100644 index 00000000000..b161859bf9c --- /dev/null +++ b/tests/ui/panics/panic-handler-closures.rs @@ -0,0 +1,10 @@ +//@ build-pass (FIXME(62277): could be check-pass?) + +#![crate_type = "rlib"] +#![no_std] + +#[panic_handler] +pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { + |x: u8| x; + loop {} +} |
