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

panic! macro should be an expression returning ! (Never type) #268

Closed
Dirbaio opened this issue Nov 23, 2020 · 0 comments · Fixed by #269
Closed

panic! macro should be an expression returning ! (Never type) #268

Dirbaio opened this issue Nov 23, 2020 · 0 comments · Fixed by #269

Comments

@Dirbaio
Copy link
Contributor

Dirbaio commented Nov 23, 2020

Code like this fails to compile, while it compiles with std panic!().

    let foo: u32 = match version {
        4 => 123,
        5 => 456,
        _ => defmt::panic!("unknown version {:?}", version),
    };
error: macro expansion ignores token `;` and any following
  --> firmware/qemu/src/bin/panic.rs:14:14
   |
14 |         _ => defmt::panic!("unknown version {:?}", version),
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: you might be missing a semicolon here: `;`
   |              |
   |              caused by the macro expansion here
   |
   = note: the usage of `defmt::panic!` is likely invalid in expression context

error[E0308]: mismatched types
  --> firmware/qemu/src/bin/panic.rs:14:14
   |
14 |         _ => defmt::panic!("unknown version {:?}", version),
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `()`
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
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 a pull request may close this issue.

1 participant