-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Bad error message when closure parameter type can't be inferred #45685
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
The code
fn main() {
let a = None;
let c = |a: Option<_>| println!("{:?}", a);
c(a)
}errors with
error[E0282]: type annotations needed
--> src/main.rs:3:14
|
2 | let a = None;
| - consider giving `a` a type
3 | let c = |a: Option<_>| println!("{:?}", a);
| ^ consider giving this closure parameter a type
which should be something like
error[E0282]: type annotations needed
--> src/main.rs:3:14
|
2 | let a = None;
| - consider giving `a` a type
3 | let c = |a: Option<_>| println!("{:?}", a);
| ^ cannot infer type for `_`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Type
Fields
Give feedbackNo fields configured for issues without a type.