Open
Description
So disclaimer, I'm not sure if this is a necessary lint (anyone with input see my rust forum post https://users.rust-lang.org/t/evaluation-order-of-boolean-subconditions/13748). But I have the feeling that boolean subcondition execution order is probably not guaranteed like in C and C++. Therefore, if a user had side-effects in a subcondition program behaviour could change significantly due to something like a changed optimisation flag.
Below is some code which should be warned against if this lint is necessary. If this is an issue I wouldn't mind implementing the lint to help out 😄
fn side_effect(i: &mut i32) -> bool {
(*i) += 1;
true
}
fn main() {
let mut i = 4;
if false && side_effect(&mut i) {
//Some code
}
println!("i is {}", i);
if side_effect(&mut i) && false {
//Some code
}
println!("i is {}", i);
}