File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -394,7 +394,6 @@ fn default_alloc_error_hook(layout: Layout) {
394394 let mut lock = crate :: sys:: backtrace:: lock ( ) ;
395395
396396 match crate :: panic:: get_backtrace_style ( ) {
397- // SAFETY: we took out a lock just a second ago.
398397 Some ( crate :: panic:: BacktraceStyle :: Short ) => {
399398 drop ( lock. print ( & mut out, crate :: backtrace_rs:: PrintFmt :: Short ) )
400399 }
Original file line number Diff line number Diff line change @@ -20,8 +20,6 @@ pub(crate) fn lock<'a>() -> BacktraceLock<'a> {
2020
2121impl BacktraceLock < ' _ > {
2222 /// Prints the current backtrace.
23- ///
24- /// NOTE: this function is not Sync. The caller must hold a mutex lock, or there must be only one thread in the program.
2523 pub ( crate ) fn print ( & mut self , w : & mut dyn Write , format : PrintFmt ) -> io:: Result < ( ) > {
2624 // There are issues currently linking libbacktrace into tests, and in
2725 // general during std's own unit tests we're not testing this path. In
@@ -36,13 +34,17 @@ impl BacktraceLock<'_> {
3634 }
3735 impl fmt:: Display for DisplayBacktrace {
3836 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
37+ // SAFETY: the backtrace lock is held
3938 unsafe { _print_fmt ( fmt, self . format ) }
4039 }
4140 }
4241 write ! ( w, "{}" , DisplayBacktrace { format } )
4342 }
4443}
4544
45+ /// # Safety
46+ ///
47+ /// This function is not Sync. The caller must hold a mutex lock, or there must be only one thread in the program.
4648unsafe fn _print_fmt ( fmt : & mut fmt:: Formatter < ' _ > , print_fmt : PrintFmt ) -> fmt:: Result {
4749 // Always 'fail' to get the cwd when running under Miri -
4850 // this allows Miri to display backtraces in isolation mode
You can’t perform that action at this time.
0 commit comments