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
Below is the minimum code that can reproduce this. With the function "test_success", async trait doesn't care about "S" being Send or not, but when I put it into a tuple (bool, &mut S), suddenly it starts to complain that "S" cannot be send between threads.
Compiling playground v0.0.1 (/playground)
error[E0277]: `S` cannot be sent between threads safely
--> src/lib.rs:6:51
|
6 | async fn test_fail(&self, _s: (bool, &mut S)) {}
| ^^
| |
| `S` cannot be sent between threads safely
| within this `{async block@src/lib.rs:6:51: 6:53}`
|
= note: required because it appears within the type `&mut S`
= note: required because it appears within the type `(bool, &mut S)`
note: required because it's used within this `async` block
--> src/lib.rs:6:51
|
6 | async fn test_fail(&self, _s: (bool, &mut S)) {}
| ^^
= note: required for the cast from `Pin<Box<{async block@src/lib.rs:6:51: 6:53}>>` to `Pin<Box<(dyn Future<Output = ()> + Send + 'async_trait)>>`
help: consider restricting type parameter `S`
|
4 | trait Test<S: std::marker::Send> {
| +++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to 1 previous error
I'm not sure what should be the correct behavior, but these two scenario seem logically the same. So I think they should either both compile fail or pass.
Thanks for this amazing crate!
The text was updated successfully, but these errors were encountered:
async_trait ersion: 0.1.83
rustc version: rustc 1.84.0-beta.5 (0857a8e32 2024-12-27)
Below is the minimum code that can reproduce this. With the function "test_success", async trait doesn't care about "S" being Send or not, but when I put it into a tuple (bool, &mut S), suddenly it starts to complain that "S" cannot be send between threads.
Here's the error message:
I'm not sure what should be the correct behavior, but these two scenario seem logically the same. So I think they should either both compile fail or pass.
Thanks for this amazing crate!
The text was updated successfully, but these errors were encountered: