Closed Kestrer closed 3 years ago
If use ::std::boxed::Box
path, cannot use async-trait on no-std environment.
Oh, then it should use ::alloc::boxed::Box
.
Yeah, but note that alloc
crate is not available without an explicit extern crate alloc
.
note that
alloc
crate is not available without an explicitextern crate alloc
.
The way to make this works correctly is a bit tricky.
It's available in function body by importing like extern crate alloc as _alloc
, but doing the same in the position of the return value can cause _alloc
to conflict with _alloc
generated by other #[async_trait]
. Probably it needs a trick, such as including the hash value of the input AST in the imported crate name.
I would like to leave this as currently implemented. Nobody should redefine Box and then expect to have boxed trait objects in the same module using a different Box.
This code:
Fails because
async-trait
usesBox
instead of::std::boxed::Box
::alloc::boxed::Box
in its macro expansion.