Closed
Description
Summary
Unsure if directly related to #8073 so I will open a separate issue. Feel free to close if it is handled in the same cases, just want to be sure this variant is handled as well. Clippy suggests removing the redundant closure but it cannot be removed because the closure return is different.
Reproducer
I tried this code:
fn exit() -> ! {
panic!()
}
fn main() {
let value = Some(8u8);
println!("{}", value.unwrap_or_else(|| exit()));
}
I expected to see this happen:
No clippy warning since the suggestion doesn't compile
Instead, this happened:
warning: redundant closure
--> src/main.rs:7:41
|
7 | println!("{}", value.unwrap_or_else(|| exit()));
| ^^^^^^^^^ help: replace the closure with the function itself: `exit`
|
= note: `#[warn(clippy::redundant_closure)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: `playground` (bin "playground") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 1.01s
Version
rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0
Additional Labels
No response