-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-inferenceArea: Type inferenceArea: Type inferenceAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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)
yfamingjeffvandyke
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-inferenceArea: Type inferenceArea: Type inferenceAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.