-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
Summary
Basically Clippy lint calls the tuple struct that I am using a function which is incorrect, and led to me being confused about what it wanted me to do.
Reproducer
I tried this code:
use std::collections::HashSet;
use std::collections::TryReserveError;
#[derive(Debug)]
enum MyError {
A(TryReserveError)
}
fn main() {
let mut hashset: HashSet<u32> = HashSet::<u32>::new();
hashset.try_reserve(10).map_err(|error| MyError::A(error)).unwrap();
}
I expected to see this happen:
Clippy should tell me that I can just call the tuple struct
Instead, this happened:
Clippy calls the tuple struct a function, which confused me.
Checking playground v0.0.1 (/playground)
warning: redundant closure
[--> src/main.rs:13:37
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e6487c80374671aecf918e801f279c42#) |
13 | hashset.try_reserve(10).map_err(|error| MyError::A(error)).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `MyError::A`
|
= 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 0.44s
```
### Version
_No response_
### Additional Labels
_No response_
hut8
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing