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
error[E0562]: `impl Trait` is not allowed in paths
--> scratch/src/main.rs:11:33
|
11 | async fn x(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> scratch/src/main.rs:11:33
|
11 | async fn x(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
After inspecting code generated by async_trait macro:
Upon inspecting the generated code by the async_trait macro, the impl Trait appears in type annotations, causing the issue. Replacing these occurrences of impl Trait with _ resolves the compilation errors.
Can the macro automatically replace all instances of impl Trait with _ to bypass this issue?
The text was updated successfully, but these errors were encountered:
Since rust 1.75, we are able to write functions that return
impl Trait
in trait.I'd like to use it with async_trait, like below:
The code upon can pass the compilation, but implementing
X
cannot.Complation error:
After inspecting code generated by
async_trait
macro:Upon inspecting the generated code by the async_trait macro, the
impl Trait
appears in type annotations, causing the issue. Replacing these occurrences ofimpl Trait
with_
resolves the compilation errors.Can the macro automatically replace all instances of
impl Trait
with_
to bypass this issue?The text was updated successfully, but these errors were encountered: