Closed
Description
use futures::{future::{BoxFuture, Future, FutureExt}};
async fn f() -> bool {
true
}
#[allow(dead_code)]
struct Foo<'a, F>
where F: Future<Output=bool> + Send {
f: Option<BoxFuture<'a, F>>,
}
impl<'a, F> Foo<'a, F>
where F: Future<Output=bool> + Send + 'a {
fn new(f: F) -> Self {
Self {
f: Some(f.boxed())
}
}
}
fn main() {
Foo::new(f());
}
I expected to see this happen:
I wish the compiler had suggested that I should change f: Option<BoxFuture<'a, F>>
to f: Option<BoxFuture<'a, F::Output>>
,
Instead, this happened:
27 | impl<'a, F> Foo<'a, F>
| - this type parameter
...
33 | f: Some(f.boxed())
| ^^^^^^^^^
| |
| expected type parameter `F`, found `bool`
| help: you need to pin and box this expression: `Box::pin(f.boxed())`
*/
Meta
Rust compiler version (stable version on play.rust-lang.org).
1.43.1
Backtrace
N/A (compile error)
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsAsync-await issues that have been triaged during a working group meeting.Category: An issue proposing an enhancement or a PR with one.Diagnostics: A structured suggestion resulting in incorrect code.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Done