rouille
rouille copied to clipboard
Unreachable code warnings with the router! macro
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 toSomecan never be reached. - This route and this route expand to something like
ret = Some(... if ... { return something } else { return something_else }). Again theSomecan'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.
FWIW even examples/hello-world.rs emits this warning.
bump!!