dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.84k stars 85 forks source link

Invalid span for generics error #166

Closed marioortizmanero closed 2 years ago

marioortizmanero commented 3 years ago

The code in this playground snippet: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=64f6ad88a914108d98ddc94816e7eafd reports an invalid error suggestion:

image

The + Send part should be after T, and not inside its own declaration; otherwise this is a syntax error.

dtolnay commented 2 years ago

This is fixed in async-trait 0.1.53.

error: future cannot be sent between threads safely
 --> src/main.rs:6:53
  |
6 |       async fn thing<T: std::fmt::Debug>(&self, x: T) {
  |  _____________________________________________________^
7 | |         todo!()
8 | |     }
  | |_____^ future created by async block is not `Send`
  |
note: captured value is not `Send`
 --> src/main.rs:6:47
  |
6 |     async fn thing<T: std::fmt::Debug>(&self, x: T) {
  |                                               ^ has type `T` which is not `Send`
  = note: required for the cast to the object type `dyn Future<Output = ()> + Send`
help: consider further restricting this bound
  |
6 |     async fn thing<T: std::fmt::Debug + std::marker::Send>(&self, x: T) {
  |                                       +++++++++++++++++++