Open
Description
In a loop, in some cases, rustc seems to not understand that a boolean expression was used for sideeffects, and warns about unused logical operation. The following code can quickly replicate the problem.
use std::sync::{atomic::{AtomicBool, Ordering}, Arc};
fn main() {
let running = Arc::new(AtomicBool::from(true));
{
let running = Arc::clone(&running);
std::thread::spawn(move || {
running.swap(false, Ordering::Relaxed);
});
}
loop {
// ...
println!("Running....");
!running.load(Ordering::Relaxed) && break;
}
println!("Exhausted >.>");
}
The expected result is that rustc doesn't output a warning in this case.
Meta
- rustc version: 1.41.0