From f84babc1b73e9085b0fe0fba5998a50438fad9fa Mon Sep 17 00:00:00 2001 From: Kenta Sato Date: Sun, 16 Feb 2025 09:45:03 +0900 Subject: [PATCH] Fix compilation error when printing `Error` with defmt This fixes compilation errors like below: ``` error[E0277]: the trait bound `nom::internal::Err>: Format` is not satisfied --> nyan.rs:245:21 | 245 | defmt::warn!("{:a}: {}", line, err); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Format` is not implemented for `nom::internal::Err>` | = help: the following other types implement trait `Format`: &T &mut T () (T0, T1) (T0, T1, T2) (T0, T1, T2, T3) (T0, T1, T2, T3, T4) (T0, T1, T2, T3, T4, T5) and 234 others = note: required for `nmea::Error<'_>` to implement `Format` note: required by a bound in `defmt::export::fmt` ``` --- src/error.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/error.rs b/src/error.rs index 98118a0..59d2aa6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -20,8 +20,9 @@ pub enum Error<'a> { /// An unknown [`GnssType`] was found in the NMEA message. UnknownGnssType(&'a str), /// The sentence could not be parsed because its format was invalid. - #[cfg_attr(feature = "defmt-03", defmt(defmt::Debug2Format))] - ParsingError(nom::Err>), + ParsingError( + #[cfg_attr(feature = "defmt-03", defmt(Debug2Format))] nom::Err>, + ), /// The sentence was too long to be parsed, our current limit is `SENTENCE_MAX_LEN` characters. SentenceLength(usize), /// Parameter was too long to fit into fixed ArrayString.