Since the attribute macro uses the Box name as-is from the prelude instead of std::boxed::Box or alloc::boxed::Box, the compiler doesn't know you don't mean the Box trait.
I would think this could be fixed by replacing Box with alloc::boxed::Box in the macro output. This would mean that extern crate alloc would have to be added to the macro output somehow.
This prevents you from writing an async trait called
Box
or usingasync_trait
when something else calledBox
is in scope.Example (playground):
This expands to
Since the attribute macro uses the Box name as-is from the prelude instead of
std::boxed::Box
oralloc::boxed::Box
, the compiler doesn't know you don't mean theBox
trait.I would think this could be fixed by replacing
Box
withalloc::boxed::Box
in the macro output. This would mean thatextern crate alloc
would have to be added to the macro output somehow.