Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop temporaries as early as possible in $:expr case #187

Merged
merged 2 commits into from
Nov 4, 2021
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Nov 4, 2021

Fixes #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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The $:expr case keeps temporaries alive longer than needed
1 participant