You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can lead to non-Sync futures for no good reason, if non-Sync temporaries inside an anyhow! expression are live across an await point.
use anyhow::anyhow;use std::cell::Cell;use std::future;fnassert_sync<T:Sync>(_:T){}fnmessage(cell:Cell<&str>) -> &str{
cell.get()}fnmain(){assert_sync(async{
future::ready(anyhow!(message(Cell::new("...")))).await;});}
error: future cannot be shared between threads safely --> src/main.rs:12:5 |12 | assert_sync(async { | ^^^^^^^^^^^ future created by async block is not `Sync` | = help: within `impl Future`, the trait `Sync` is not implemented for `Cell<&str>`note: future is not `Sync` as this value is used across an await --> src/main.rs:13:9 |13 | future::ready(anyhow!(message(Cell::new("...")))).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first, await occurs here, with `Cell::new("...")` maybe used later...note: `Cell::new("...")` is later dropped here --> src/main.rs:13:64 |13 | future::ready(anyhow!(message(Cell::new("...")))).await; | ---------------- ^ | | | has type `Cell<&str>` which is not `Sync`note: required by a bound in `assert_sync` --> src/main.rs:5:19 |5 | fn assert_sync<T: Sync>(_: T) {} | ^^^^ required by this bound in `assert_sync`
The text was updated successfully, but these errors were encountered:
This can lead to non-Sync futures for no good reason, if non-Sync temporaries inside an
anyhow!
expression are live across an await point.The text was updated successfully, but these errors were encountered: