-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
estebank and Bear-03
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.