Skip to content

Commit 45f6545

Browse files
committed
Add regression test of issue 186
Currently fails to build without the fix: error: future cannot be shared between threads safely --> tests/test_macros.rs:64:5 | 64 | require_send_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 --> tests/test_macros.rs:65:9 | 65 | future::ready(anyhow!(message(Cell::new("...")))).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first, await occurs here, with `Cell::new("...")` maybe used later... note: `Cell::new("...")` is later dropped here --> tests/test_macros.rs:65:64 | 65 | future::ready(anyhow!(message(Cell::new("...")))).await; | ---------------- ^ | | | has type `Cell<&str>` which is not `Sync` note: required by a bound in `require_send_sync` --> tests/test_macros.rs:50:41 | 50 | fn require_send_sync(_: impl Send + Sync) {} | ^^^^ required by this bound in `require_send_sync`
1 parent fb3e4b7 commit 45f6545

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_macros.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mod common;
1010

1111
use self::common::*;
1212
use anyhow::{anyhow, ensure};
13+
use std::cell::Cell;
1314
use std::future;
1415

1516
#[test]
@@ -61,6 +62,14 @@ fn test_temporaries() {
6162
// enclosing future non-Send.
6263
future::ready(anyhow!("...")).await;
6364
});
65+
66+
fn message(cell: Cell<&str>) -> &str {
67+
cell.get()
68+
}
69+
70+
require_send_sync(async {
71+
future::ready(anyhow!(message(Cell::new("...")))).await;
72+
});
6473
}
6574

6675
#[test]

0 commit comments

Comments
 (0)