Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation error when printing Error with defmt #146

Merged
merged 2 commits into from
Feb 16, 2025

Conversation

Tosainu
Copy link
Contributor

@Tosainu Tosainu commented Feb 16, 2025

This fixes compilation errors like below:

error[E0277]: the trait bound `nom::internal::Err<nom::error::Error<&str>>: Format` is not satisfied
   --> nyan.rs:245:21
    |
245 |                     defmt::warn!("{:a}: {}", line, err);
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Format` is not implemented for `nom::internal::Err<nom::error::Error<&str>>`
    |
    = 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`

The position of adding the #[defmt()] attribute seems to be wrong according to the document. So I moved this inside the ParsingError( ... ) and I verified it now compiles and works.

This fixes compilation errors like below:
```
error[E0277]: the trait bound `nom::internal::Err<nom::error::Error<&str>>: Format` is not satisfied
   --> nyan.rs:245:21
    |
245 |                     defmt::warn!("{:a}: {}", line, err);
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Format` is not implemented for `nom::internal::Err<nom::error::Error<&str>>`
    |
    = 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`
```
@elpiel
Copy link
Member

elpiel commented Feb 16, 2025

Good catch!
Will merge once CI passes.

Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.67%. Comparing base (68a44c0) to head (8daf104).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #146   +/-   ##
=======================================
  Coverage   78.67%   78.67%           
=======================================
  Files          39       39           
  Lines        1449     1449           
=======================================
  Hits         1140     1140           
  Misses        309      309           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@elpiel elpiel merged commit 17fb066 into AeroRust:main Feb 16, 2025
15 checks passed
@Tosainu Tosainu deleted the fix-printing-error-with-defmt branch February 16, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants