dtolnay / async-trait

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

Cryptic error message on missing `async` #179

Closed vporton closed 3 years ago

vporton commented 3 years ago

If I forget async in fn declaration in an async trait but don't forget in its implementation in an impl of a struct, the Rust error message is cryptic:

lifetime parameters or bounds on method `get_upstream_stream` do not match the trait declaration
lifetimes do not match method in traitrustcE0195
cache.rs(73, 27): lifetimes in impl do not match this method in trait
View Problem

Sorry, I'm too busy now to give details.

dtolnay commented 3 years ago

Seems like it's your editor that is rendering that particularly unhelpfully. The real diagnostic from rustc is as follows, which clearly shows the difference in async.

https://github.com/dtolnay/async-trait/blob/a375e65f4075065ece16c2e828aaf21041a8cd7d/tests/ui/missing-async-in-trait.stderr#L1-L8