From 2614bd2ae163a0b555ad2677c75c7261f0abcea7 Mon Sep 17 00:00:00 2001 From: Konippi Date: Fri, 2 Aug 2024 00:24:29 +0900 Subject: [PATCH] chore: refactor backtrace formatting --- std/src/error.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/std/src/error.rs b/std/src/error.rs index f5905605e7887..3e17431af45b0 100644 --- a/std/src/error.rs +++ b/std/src/error.rs @@ -500,13 +500,8 @@ where } if self.show_backtrace { - let backtrace = self.backtrace(); - - if let Some(backtrace) = backtrace { - let backtrace = backtrace.to_string(); - - f.write_str("\n\nStack backtrace:\n")?; - f.write_str(backtrace.trim_end())?; + if let Some(backtrace) = self.backtrace() { + write!(f, "\n\nStack backtrace:\n{}", backtrace.to_string().trim_end())?; } }