rust-embedded / nb

Minimal and reusable non-blocking I/O layer
Apache License 2.0
86 stars 15 forks source link

Warnings in block!, if error type is ! #5

Closed hannobraun closed 6 years ago

hannobraun commented 6 years ago

I've implemented embedded_hal::serial::Write in my code. In my case, errors can only be returned on receive, so Error is !, as per the recommendation in the documentation.

I've temporarily replaced the code in my old (blocking) write method with this:

block!(<Self as Write<u8>>::write(self, data))
    .expect("Write operation should never result in error");

This results in the following warnings:

warning: unreachable expression
   --> src/uart.rs:151:9
    |
151 |         block!(<Self as Write<u8>>::write(self, data))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(unreachable_code)] on by default
    = note: this error originates in a macro outside of the current crate

warning: unreachable pattern
   --> src/uart.rs:151:9
    |
151 |         block!(<Self as Write<u8>>::write(self, data))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(unreachable_patterns)] on by default
    = note: this error originates in a macro outside of the current crate

If I change Error to (), the warnings disappear.