-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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
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)
benbrittain, ThouCheese and msrd0
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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.
Type
Projects
Status
Done