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

format string parser error should point to the docs #536

Closed
japaric opened this issue Jul 16, 2021 · 2 comments · Fixed by #735
Closed

format string parser error should point to the docs #536

japaric opened this issue Jul 16, 2021 · 2 comments · Fixed by #735
Assignees
Labels
difficulty: easy Pretty easy to solve priority: medium Medium priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: documentation Fixes, improvements or additions to the documentation

Comments

@japaric
Copy link
Member

japaric commented Jul 16, 2021

For example:

ERROR: Format string error detected.
HELP: `defmt` uses a slightly different syntax than regular formatting in Rust.
  See https://defmt.ferrous-systems.com/macros.html for more details.
@Urhengulas Urhengulas added difficulty: easy Pretty easy to solve status: needs PR Issue just needs a Pull Request implementing the changes type: documentation Fixes, improvements or additions to the documentation priority: medium Medium priority for the Knurling team labels Jul 16, 2021
@jonathanpallant
Copy link
Contributor

jonathanpallant commented Mar 8, 2023

Currently you see:

defmt::println!("Hello, world!, p1 = {:z}", p);
error: unknown display hint: "z"
  --> src/bin/hello.rs:12:21
   |
12 |     defmt::println!("Hello, world!, p1 = {:z}", p);
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `test-pointers` due to previous error

@jonathanpallant
Copy link
Contributor

I have something that now shows:

error: unknown display hint: `"z"`

         = help: `defmt` uses a slightly different syntax than regular formatting in Rust. See https://defmt.ferrous-systems.com/macros.html for more details.

  --> src/bin/hello.rs:12:21
   |
12 |     defmt::println!("Hello, world!, p1 = {:z}", p);
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `test-pointers` due to previous error

@jonathanpallant jonathanpallant self-assigned this Mar 8, 2023
bors bot added a commit that referenced this issue Mar 10, 2023
735: Fix #536 - add help for format string parsing error r=Urhengulas a=jonathanpallant

1) Replaces `Cow<str>` with an `enum Error` to accurately describe the parse error
2) Uses `thiserror` to convert the `Error` enum into strings, which match the strings previously returned from the `parse` function
3) Uses that enum to add help text for Error::UnknownDisplayHint.

Closes #536 

Co-authored-by: Jonathan Pallant (Ferrous Systems) <jonathan.pallant@ferrous-systems.com>
Co-authored-by: Johann Hemmann <johann.hemmann@code.berlin>
@bors bors bot closed this as completed in 9d2bfde Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy Pretty easy to solve priority: medium Medium priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: documentation Fixes, improvements or additions to the documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants