-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-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 tried this code:
struct Foo;
async fn foo(x: &Foo, y: &Foo, z: &'static Foo) {}I expected to see this happen: The function should compile and be a no-op
Instead, this happened: The code fails to compile with the following error message
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
--> src/lib.rs:3:49
|
3 | async fn foo(x: &Foo, y: &Foo, z: &'static Foo) {}
| ^
|
Meta
rustc --version --verbose:
1.46.0
I have reproduced this issue with 1.46.0 as well as nightly 1.48.0 2020-09-08, both in the Rust playground.
Solutions I tried:
| Code | Summary | Result |
|---|---|---|
async fn foo<'a>(x: &'a Foo, y: &'a Foo, z: &'static Foo) {} |
Constraining x and y to the same lifetime |
COMPILES |
async fn foo(x: &Foo, y: &Foo, z: &Foo) {} |
removing the static lifetime on z |
COMPILES |
async fn foo(x: &Foo, z: &'static Foo) {} |
removing x, y, or z |
COMPILES |
async fn foo<'x, 'y>(x: &'x Foo, y: &'y Foo, z: &'static Foo) {} |
Constraining x and y to independent lifetimes |
FAILS TO COMPILE |
async fn foo<'x, 'y: 'x>(x: &'x Foo, y: &'y Foo, z: &'static Foo) {} |
Constraining x and y to lifetimes that are not independent |
COMPILES |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-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.