- Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)C-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.F-async_fn_in_traitStatic async fn in traitsStatic async fn in traitsF-return_type_notation`#[feature(return_type_notation)]``#[feature(return_type_notation)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)C-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.F-async_fn_in_traitStatic async fn in traitsStatic async fn in traitsF-return_type_notation`#[feature(return_type_notation)]``#[feature(return_type_notation)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Status
Non-blocking