While a == 10 incorrect?
โ Rust ๐ 2025-11-22 ๐ค surdeus ๐๏ธ 11Why does the rustc compiler successfully compile code that contains a logically incorrect condition?
fn main() {
let mut a = 1;
while a == 10 {
println!("{}", a);
a += 1;
}
}
The compiled binary doesnโt produce any output, but intuitively, the compiler should detect that the loop condition (a == 10) will never be true.
4 posts - 4 participants
๐ท๏ธ Rust_feed