Open
Description
Summary
#[allow(clippy::redundant_closure)]
that worked until Rust 1.81 seems to have broken in Rust 1.82. Specifically, clippy::redundant_closure
can no longer be suppressed with #[allow(...)]
in Rust 1.82 (I haven't tested whether subsequent Rust versions exhibit the same issue).
Reproducer
I tried this code:
// src/main.rs
#[allow(dead_code)]
struct Foo(i32);
impl Foo {
fn new(i: i32) -> Self {
Self(i)
}
}
fn main() {
let i = Some(1);
let _f = i.map(
#[allow(clippy::redundant_closure)]
|i| Foo::new(i),
);
}
I expected no warning from cargo clippy
(which is the case for Rust 1.81)
$ cargo clippy
...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
Instead, this happened:
$ cargo clippy
warning: redundant closure
--> src/main.rs:13:9
|
13 | |i| Foo::new(i),
| ^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Foo::new`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
= note: `#[warn(clippy::redundant_closure)]` on by default
$ cargo --version
cargo 1.82.0 (8f40fc59f 2024-08-21)
Version
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: aarch64-apple-darwin
release: 1.82.0
LLVM version: 19.1.1
Additional Labels
No response