Closed
Description
#![feature(unboxed_closures)]
#![feature(overloaded_calls)]
fn action<T: Send, F: FnOnce(Sender<T>) -> ()>(sender: Sender<T>, cb: F) {
cb(sender);
}
pub fn main() {
let (tx, rx) = channel();
// Must be uncommented to work vvv
action(tx, move |:tx /* :Sender<&'static str> */| {
tx.send("zomg")
});
println!("recv: {}", rx.recv());
}
Output:
rustc fnonce.rs
fnonce.rs:13:7: 13:22 error: the type of this value must be known in this context
fnonce.rs:13 tx.send("zomg")
^~~~~~~~~~~~~~~
fnonce.rs:12:3: 12:9 error: type mismatch: the type `closure` implements the trait `core::ops::FnOnce<([type error]),[type error]>`, but the trait `core::ops::FnOnce<(sync::comm::Sender<<generic #9>>),()>` is required (expected struct sync::comm::Sender, found type error)
fnonce.rs:12 action(tx, move |:tx /* :Sender<&'static str> */| {
^~~~~~
fnonce.rs:12:3: 12:9 note: the trait `core::ops::FnOnce` must be implemented because it is required by `action`
fnonce.rs:12 action(tx, move |:tx /* :Sender<&'static str> */| {
^~~~~~
error: aborting due to 2 previous errors
Metadata
Metadata
Assignees
Labels
No labels