From a30c36c92a68862b5390ce5d8744f9036d047884 Mon Sep 17 00:00:00 2001 From: liquidev Date: Sun, 1 Sep 2024 19:20:09 +0200 Subject: [PATCH] fix compilation errors on release mode due to missing #[cfg(debug_assertions)] with parser event tracing --- crates/haku/src/parser.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/crates/haku/src/parser.rs b/crates/haku/src/parser.rs index 5be0d3b..3d9ea09 100644 --- a/crates/haku/src/parser.rs +++ b/crates/haku/src/parser.rs @@ -228,6 +228,7 @@ impl Event { fn new(kind: EventKind) -> Event { Event { kind, + #[cfg(debug_assertions)] from: core::panic::Location::caller(), } } @@ -235,14 +236,24 @@ impl Event { impl fmt::Debug for Event { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "{:?} @ {}:{}:{}", - self.kind, - self.from.file(), - self.from.line(), - self.from.column() - ) + #[cfg(debug_assertions)] + { + write!( + f, + "{:?} @ {}:{}:{}", + self.kind, + self.from.file(), + self.from.line(), + self.from.column() + )?; + } + + #[cfg(not(debug_assertions))] + { + write!(f, "{:?}", self.kind,)?; + } + + Ok(()) } }