rouille icon indicating copy to clipboard operation
rouille copied to clipboard

Unreachable code warnings with the router! macro

Open tomaka opened this issue 9 years ago • 2 comments

In the nightly the tests (and real code) that use the router! macro are sometimes currently producing warnings about unreachable code.

  • This line expands to something like ret = Some(panic!("Oops!")). The compiler complains that the call to Some can never be reached.
  • This route and this route expand to something like ret = Some(... if ... { return something } else { return something_else }). Again the Some can't be reached.

Unfortunately as far as I know there's no way to fix these warnings in the macro itself. If we wrap the user's code inside a closure, it successfully removes the warnings but then return would refer to that closure, which would be very counterintuitive. The proper solution would be https://github.com/rust-lang/rust/issues/15701 which would allow one to add #[allow(unreachable_code)] on the Some itself.

tomaka avatar Dec 16 '16 09:12 tomaka

FWIW even examples/hello-world.rs emits this warning.

bestouff avatar Dec 08 '18 14:12 bestouff

bump!!

drbh avatar Aug 29 '19 22:08 drbh