about summary refs log tree commit diff
path: root/library/std/src/backtrace.rs
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-10 16:17:38 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-12 08:53:59 +0000
commit0bc2001879558ba0d51b6a246f5178853f9ff21e (patch)
tree5747a489de57f4aed39d2e9c9477a02b1ab7744d /library/std/src/backtrace.rs
parent39e7bf6826946bea847b8680e73cbca12c8d9732 (diff)
downloadrust-0bc2001879558ba0d51b6a246f5178853f9ff21e.tar.gz
rust-0bc2001879558ba0d51b6a246f5178853f9ff21e.zip
Require any function with a tait in its signature to actually constrain a hidden type
Diffstat (limited to 'library/std/src/backtrace.rs')
-rw-r--r--library/std/src/backtrace.rs60
1 files changed, 32 insertions, 28 deletions
diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs
index 475b3e7eb93..e3e0cde8afe 100644
--- a/library/std/src/backtrace.rs
+++ b/library/std/src/backtrace.rs
@@ -428,39 +428,43 @@ impl fmt::Display for Backtrace {
     }
 }
 
-type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe;
-
-fn lazy_resolve(mut capture: Capture) -> LazyResolve {
-    move || {
-        // Use the global backtrace lock to synchronize this as it's a
-        // requirement of the `backtrace` crate, and then actually resolve
-        // everything.
-        let _lock = lock();
-        for frame in capture.frames.iter_mut() {
-            let symbols = &mut frame.symbols;
-            let frame = match &frame.frame {
-                RawFrame::Actual(frame) => frame,
-                #[cfg(test)]
-                RawFrame::Fake => unimplemented!(),
-            };
-            unsafe {
-                backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
-                    symbols.push(BacktraceSymbol {
-                        name: symbol.name().map(|m| m.as_bytes().to_vec()),
-                        filename: symbol.filename_raw().map(|b| match b {
-                            BytesOrWideString::Bytes(b) => BytesOrWide::Bytes(b.to_owned()),
-                            BytesOrWideString::Wide(b) => BytesOrWide::Wide(b.to_owned()),
-                        }),
-                        lineno: symbol.lineno(),
-                        colno: symbol.colno(),
+mod helper {
+    use super::*;
+    pub(super) type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe;
+
+    pub(super) fn lazy_resolve(mut capture: Capture) -> LazyResolve {
+        move || {
+            // Use the global backtrace lock to synchronize this as it's a
+            // requirement of the `backtrace` crate, and then actually resolve
+            // everything.
+            let _lock = lock();
+            for frame in capture.frames.iter_mut() {
+                let symbols = &mut frame.symbols;
+                let frame = match &frame.frame {
+                    RawFrame::Actual(frame) => frame,
+                    #[cfg(test)]
+                    RawFrame::Fake => unimplemented!(),
+                };
+                unsafe {
+                    backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| {
+                        symbols.push(BacktraceSymbol {
+                            name: symbol.name().map(|m| m.as_bytes().to_vec()),
+                            filename: symbol.filename_raw().map(|b| match b {
+                                BytesOrWideString::Bytes(b) => BytesOrWide::Bytes(b.to_owned()),
+                                BytesOrWideString::Wide(b) => BytesOrWide::Wide(b.to_owned()),
+                            }),
+                            lineno: symbol.lineno(),
+                            colno: symbol.colno(),
+                        });
                     });
-                });
+                }
             }
-        }
 
-        capture
+            capture
+        }
     }
 }
+use helper::*;
 
 impl RawFrame {
     fn ip(&self) -> *mut c_void {