mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
25 lines
533 B
Rust
25 lines
533 B
Rust
//@no-rustfix
|
|
#![warn(clippy::never_loop)]
|
|
#![expect(clippy::needless_return)]
|
|
|
|
fn main() {
|
|
// diverging closure with no `return`: should trigger
|
|
[0, 1].into_iter().for_each(|x| {
|
|
//~^ never_loop
|
|
|
|
let _ = x;
|
|
panic!("boom");
|
|
});
|
|
|
|
// benign closure: should NOT trigger
|
|
[0, 1].into_iter().for_each(|x| {
|
|
let _ = x + 1;
|
|
});
|
|
|
|
// `return` should NOT trigger even though it is diverging
|
|
[0, 1].into_iter().for_each(|x| {
|
|
println!("x = {x}");
|
|
return;
|
|
});
|
|
}
|