diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index f0e199fac737c..e7110aebdea16 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -92,6 +92,7 @@ use crate::backtrace_rs::{self, BytesOrWideString}; use crate::env; use crate::ffi::c_void; use crate::fmt; +use crate::panic::UnwindSafe; use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed}; use crate::sync::LazyLock; use crate::sys_common::backtrace::{lock, output_filename}; @@ -427,7 +428,7 @@ impl fmt::Display for Backtrace { } } -type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync; +type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe; fn lazy_resolve(mut capture: Capture) -> LazyResolve { move || { diff --git a/library/std/src/backtrace/tests.rs b/library/std/src/backtrace/tests.rs index ef419806dccbd..73543a3af548f 100644 --- a/library/std/src/backtrace/tests.rs +++ b/library/std/src/backtrace/tests.rs @@ -1,4 +1,5 @@ use super::*; +use crate::panic::{RefUnwindSafe, UnwindSafe}; fn generate_fake_frames() -> Vec { vec![ @@ -91,3 +92,9 @@ fn test_frames() { assert!(iter.all(|(f, e)| format!("{f:#?}") == *e)); } + +#[test] +fn backtrace_unwind_safe() { + fn assert_unwind_safe() {} + assert_unwind_safe::(); +}