Closed
Description
let foo = Mutex::new("123");
let foo: Box<dyn futures::future::Future<Output = ()> + Send> = Box::new(async move {
// In a separate block works
// {
let bar = foo.lock().unwrap();
drop(bar);
// }
futures::future::lazy(|_| ()).await;
});
Fails with
error[E0277]: `std::sync::MutexGuard<'_, &str>` cannot be sent between threads safely
When putting the lock into a separate block it works fine, when not awaiting or locking after the last await point it also works fine.
It seems that dropped values at await points are still considered in scope and borrowed.