-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-async-closures`async || {}``async || {}`A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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
Code
fn main() {
let a = 0;
async move || {
require_static(&a);
};
}
fn require_static(_: &'static i32) {}Current output
error: lifetime may not live long enough
--> src/main.rs:3:19
|
3 | async move || {
| _____-------------_^
| | |
| | lifetime `'1` represents this closure's body
4 | | require_static(&a);
5 | | };
| |_____^ returning this value requires that `'1` must outlive `'static`
|
= note: closure implements `Fn`, so references to captured variables can't escape the closureDesired output
Rationale and extra context
This async closure does not implement Fn.
Other cases
Rust Version
Reproducible on the playground with version 1.93.0-nightly (2025-11-01 bd3ac0330018c23b111b)Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-async-closures`async || {}``async || {}`A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.