rust
rust copied to clipboard
Unreachable code warning missing at if expression with false condition
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6526368602dd7742a2bd1d988fe03f66
let a: u32 = 3;
if a < a {
panic!();
}
if 3 > 3 {
panic!();
}
if false {
panic!();
}
The current output is: nothing Can be reproduced on versions 1.55-nightly and 1.53.
Ideally this code should trigger the unreachable_code
lint at least in the case when an integer variable is compared with itself, to prevent mistakes such as typos.
AFAIK, this code is eliminated when optimizations are turned on, so the warning should follow along.
I'm not sure if the case when the conditional expression is exactly false
should be considered a warning, since it is probably not a mistake.
@rustbot modify labels: +A-lint