Open
Description
I tried this code:
#![feature(return_type_notation)]
#![feature(async_fn_in_trait)]
trait HealthCheck {
async fn check<'a: 'a>(&'a mut self) -> bool;
}
async fn do_health_check_par<HC>(hc: HC)
where
HC: HealthCheck<check(): Send> + Send + 'static,
{
tokio::task::spawn(async move {
let mut hc = hc;
if !hc.check().await {
log_health_check_failure().await;
}
});
}
async fn log_health_check_failure() {}
I expected to see this happen: it works
Instead, this happened:
error: higher-ranked lifetime error
--> src/lib.rs:12:5
|
12 | / tokio::task::spawn(async move {
13 | | let mut hc = hc;
14 | | if !hc.check().await {
15 | | log_health_check_failure().await;
16 | | }
17 | | });
| |______^
|
= note: could not prove `[async block@src/lib.rs:12:24: 17:6]: Send`
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Category: This is a bug.Diagnostics: Confusing error or lint that should be reworked.Static async fn in traits`#[feature(return_type_notation)]`Relevant to the types team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.
Type
Projects
Status
Non-blocking