-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Description
While trying to learn how to return a closure.... I came across this..
fn foo(x: i32) {
|y| x + y
}
fn main() {
let x = foo(5)(2);
}gives....
2:12 error: can't infer the "kind" of the closure, explicitly annotate it. e.g. `|&:| {}`
src/hello_world.rs:2 |y| x + y
^~~~~~~~~
src/hello_world.rs:2:3: 2:12 error: mismatched types: expected `()`, found `closure[src/hello_world.rs:2:3: 2:12]` (expected (), found closure)
src/hello_world.rs:2 |y| x + y
^~~~~~~~~
src/hello_world.rs:6:11: 6:20 error: expected function, found `()`
src/hello_world.rs:6 let x = foo(5)(2);
^~~~~~~~~
src/hello_world.rs:6:11: 6:17 error: internal compiler error: unexpected callee type ()
src/hello_world.rs:6 let x = foo(5)(2);
^~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:123
Metadata
Metadata
Assignees
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️