Skip to content
Myr

Add regression test of issue 186

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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`

authored by David Tolnay · committed by David Tolnay · parent fb3e4b7 · Browse files · 1 file+9 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−0 removed

  • tests:+9 added−0 removed

1 file+9 added−0 removed

modified:tests/test_macros.rs+9 added
8 unmodified lines
9mod common;1011use self::common::*;12use anyhow::{anyhow, ensure};13use std::cell::Cell;14use std::future;1516#[test]17fn test_messages() {
43 unmodified lines
61 // semicolon, which is on the other side of the await point, making the62 // enclosing future non-Send.63 future::ready(anyhow!("...")).await;64 });6566 fn message(cell: Cell<&str>) -> &str {67 cell.get()68 }6970 require_send_sync(async {71 future::ready(anyhow!(message(Cell::new("...")))).await;72 });73}7475#[test]76fn test_brace_escape() {
3 unmodified lines