Closed
Description
i have following fn that works completly fine:
pub fn test1() -> Box<dyn Debug> {
Box::new("asdf")
}
if i try trivialy make it async just by adding async
keyword i get build error:
error[E0271]: type mismatch resolving `<impl core::future::future::Future as core::future::future::Future>::Output == std::boxed::Box<(dyn std::fmt::Debug + 'static)>`
--> comix_downloader_lib_async/src/lib.rs:49:25
|
49 | pub async fn test1() -> Box<dyn Debug> {
| ^^^^^^^^^^^^^^ expected &str, found trait std::fmt::Debug
|
= note: expected type `std::boxed::Box<&str>`
found type `std::boxed::Box<(dyn std::fmt::Debug + 'static)>`
= note: the return type of a function must have a statically known size
i can work around this by defining types of variables explicitly:
pub async fn test3() -> Box<dyn Debug> {
let tmp : Box<dyn Debug> = Box::new("asdf");
tmp
}
but for obvious reasons this is not as nice as sync version
maybe related to #60414 ?
rustc --version
: rustc 1.36.0-nightly (00859e3e6 2019-04-29)