I have the following error (vastly truncated):
error[E0284]: type annotations required: cannot resolve `the closure `copy_changeset::{{closure}}` implements the trait `FnOnce``
--> scm/mononoke/cmds/blobimport.rs:331:29
|
331 | .map(|copy| cpupool.spawn(copy))
| ^^^^^
|
= note: required because of the requirements on the impl of `futures::Future` for `futures::AndThen<futures::future::FromErr<std::boxed::Box<futures::Future<Error=mercurial::Error, Item=mercurial::changeset::RevlogChangeset> + std::marker::Send + 'static>, Error>, futures::MapErr<std::boxed::Box<futures::Future<Error=blobrepo::Error, Item=()> + std::marker::Send + 'static>, fn(blobrepo::Error) -> Error {<blobrepo::Error as std::convert::Into<Error>>::into}>, [closure@scm/mononoke/cmds/blobimport.rs:239:23: 243:14 csid:mercurial_types::NodeHash, blobstore:std::sync::Arc<blobstore::Blobstore<GetBlob=std::boxed::Box<futures::Future<Error=Error, Item=std::option::Option<std::vec::Vec<u8>>> + std::marker::Send + 'static>, ValueOut=std::vec::Vec<u8>, Key=std::string::String, Error=Error, ValueIn=bytes::Bytes, PutBlob=std::boxed::Box<futures::Future<Error=Error, Item=()> + std::marker::Send + 'static>> + std::marker::Sync + 'static>]>`
(full errors here)
I have a function which contains a series of combinators including an .and_then()
that takes a closure, and then the function returns impl Future<...>
for the whole thing. That eventually gets passed into CpuPool::spawn
- but the compiler complains that "copy_changeset::{{closure}}
" doesn't implement FnOnce
. I assume it means the closure being passed to .and_then()
, but I'm not sure why it isn't implementing FnOnce
.
I wonder if being passed through impl Future
has erased that bit of type information? What type annotation does is it actually looking for?
The full source for that file is here but I haven't constructed a standalone example that can be compiled yet.
(That type somewhat pretty-printed is:
futures::AndThen<
futures::future::FromErr<
std::boxed::Box<
futures::Future<
Error=mercurial::Error, Item=mercurial::changeset::RevlogChangeset
> + std::marker::Send + 'static
>,
Error
>,
futures::MapErr<
std::boxed::Box<
futures::Future<
Error=blobrepo::Error, Item=()
> + std::marker::Send + 'static
>,
fn(blobrepo::Error) -> Error {<
blobrepo::Error as std::convert::Into<
Error
>
>::into}
>,
[closure@scm/mononoke/cmds/blobimport.rs:239:23: 243:14
csid:mercurial_types::NodeHash,
blobstore:std::sync::Arc<
blobstore::Blobstore<
GetBlob=std::boxed::Box<
futures::Future<
Error=Error, Item=std::option::Option< std::vec::Vec<u8> >
> + std::marker::Send + 'static
>, ValueOut=std::vec::Vec< u8 >,
Key=std::string::String,
Error=Error, ValueIn=bytes::Bytes,
PutBlob=std::boxed::Box<
futures::Future<
Error=Error, Item=()
> + std::marker::Send + 'static
>
> + std::marker::Sync + 'static
>
]
>
)