Open
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.