Closed
Description
//* f hits lifetime errors
fn f(a: &usize) -> (impl '_ + Future<Output = ()>, &usize) {
(async { *a; }, a)
}
// */
// g compiles as expected
fn g(a: &usize) -> (impl '_ + Future<Output = ()>, &usize) {
async fn h(a: &usize) { *a; }
(h(a), a)
}
error[E0515]: cannot return value referencing function parameter `a`
--> src/main.rs:5:5
|
5 | (async { *a; }, a)
| ^^^^^^^^^^-^^^^^^^
| | |
| | `a` is borrowed here
| returns a value referencing data owned by the current function
This issue has been assigned to @gizmondo via this comment.
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsAsync-await issues that have been triaged during a working group meeting.Category: An issue proposing an enhancement or a PR with one.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.
Type
Projects
Status
Done