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

Bypass Sync bound implied by non-existent drop of reference #233

Merged
merged 2 commits into from
Jan 22, 2023

Commits on Jan 22, 2023

  1. Add regression test for issue 232

    Currently fails to compile:
    
        error: future cannot be sent between threads safely
            --> tests/test.rs:1506:41
             |
        1506 |         async fn take_ref(&self, _: &T) {}
             |                                         ^^ future created by async block is not `Send`
             |
        note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync`
            --> tests/test.rs:1506:34
             |
        1504 |     #[async_trait]
             |     -------------- in this procedural macro expansion
        1505 |     impl<T> Generic<T> for One {
        1506 |         async fn take_ref(&self, _: &T) {}
             |                                  ^ has type `&T` which is not `Send`, because `T` is not `Sync`
             = note: required for the cast from `[async block@tests/test.rs:1506:41: 1506:43]` to the object type `dyn futures::Future<Output = ()> + std::marker::Send`
             = note: this error originates in the attribute macro `async_trait` (in Nightly builds, run with -Z macro-backtrace for more info)
        help: consider restricting type parameter `T`
             |
        1505 |     impl<T: std::marker::Sync> Generic<T> for One {
             |           +++++++++++++++++++
    
        error[E0277]: `T` cannot be shared between threads safely
            --> tests/test.rs:1523:60
             |
        1523 |         async fn take_ref(&self, (_a, _b, _c): &(T, T, T)) {}
             |                                                            ^^ `T` cannot be shared between threads safely
             |
             = note: required because it appears within the type `(T, T, T)`
             = note: required for `&(T, T, T)` to implement `std::marker::Send`
        note: required because it's used within this `async` block
            --> tests/test.rs:1523:60
             |
        1523 |         async fn take_ref(&self, (_a, _b, _c): &(T, T, T)) {}
             |                                                            ^^
             = note: required for the cast from `[async block@tests/test.rs:1523:60: 1523:62]` to the object type `dyn futures::Future<Output = ()> + std::marker::Send`
        help: consider restricting type parameter `T`
             |
        1522 |     impl<T: std::marker::Sync> Generic<(T, T, T)> for Three {
             |           +++++++++++++++++++
    dtolnay committed Jan 22, 2023
    Configuration menu
    Copy the full SHA
    70bf4b0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ba93025 View commit details
    Browse the repository at this point in the history