-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.
Description
The following code is failing to compile in stable and nightly
fn main() {
let a = |hello| { return hello + 1; };
let _ = a(2);
}
with the following message:
rustc 1.15.0 (10893a9a3 2017-01-19)
error[E0271]: type mismatch resolving `<i32 as std::ops::Add>::Output == ()`
--> <anon>:2:30
|
2 | let a = |hello| { return hello + 1; };
| ^^^^^^^^^ expected i32, found ()
|
= note: expected type `i32`
= note: found type `()`
error: aborting due to previous error
If I remove the return and the semicolon, it works as expected.
Adding the type i32
to _
or adding a type to the parameter (e.g.: 2u32
) fixes the problem.
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.