Open
Description
Running stable 1.64.0.
Unfortunately this happened in a complex bit of code that I can't easily reduce :(
task::spawn({
let handle_service = handle_service.clone();
async move {
if let Err(e) = handle_service.call(connection).await {
debug!("http connection terminated", error: e);
}
}
});
error: higher-ranked lifetime error
--> witchcraft-server/src/server.rs:118:13
|
118 | / task::spawn({
119 | | let handle_service = handle_service.clone();
120 | | async move {
121 | | if let Err(e) = handle_service.call(connection).await {
... |
124 | | }
125 | | });
| |______________^
|
= note: could not prove `for<'r> impl for<'r> futures_util::Future<Output = ()>: std::marker::Send`
The future returned by handle_service.call(connection)
is definitely Send
, and I can work around the failure by boxing it:
task::spawn({
let handle_service = handle_service.clone();
async move {
// The compiler hits a `higher-ranked lifetime error` if we don't box this future :/
let f: Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> =
Box::pin(handle_service.call(connection));
if let Err(e) = f.await {
debug!("http connection terminated", error: e);
}
}
});