Implement UnwindSafe and RefUnwindSafe for Backtrace
Backtrace doesn't have visible mutable state.
This commit is contained in:
parent
03b8b50fcb
commit
0f06b07552
@ -92,6 +92,7 @@ use crate::backtrace_rs::{self, BytesOrWideString};
|
|||||||
use crate::env;
|
use crate::env;
|
||||||
use crate::ffi::c_void;
|
use crate::ffi::c_void;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
|
use crate::panic::UnwindSafe;
|
||||||
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||||
use crate::sync::LazyLock;
|
use crate::sync::LazyLock;
|
||||||
use crate::sys_common::backtrace::{lock, output_filename};
|
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 {
|
fn lazy_resolve(mut capture: Capture) -> LazyResolve {
|
||||||
move || {
|
move || {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
|
|
||||||
fn generate_fake_frames() -> Vec<BacktraceFrame> {
|
fn generate_fake_frames() -> Vec<BacktraceFrame> {
|
||||||
vec![
|
vec![
|
||||||
@ -91,3 +92,9 @@ fn test_frames() {
|
|||||||
|
|
||||||
assert!(iter.all(|(f, e)| format!("{f:#?}") == *e));
|
assert!(iter.all(|(f, e)| format!("{f:#?}") == *e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn backtrace_unwind_safe() {
|
||||||
|
fn assert_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}
|
||||||
|
assert_unwind_safe::<Backtrace>();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user