Closed
Description
pub async fn async_fn(x: &mut i32) -> (&i32, &i32) {
let y = &*x;
*x += 1;
(&32, y)
}
Output (playground):
error[E0506]: cannot assign to `*x` because it is borrowed
--> src/lib.rs:3:5
|
2 | let y = &*x;
| --- borrow of `*x` occurs here
3 | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here
4 | (&32, y)
| -------- returning this value requires that `*x` is borrowed for `'1`
5 | }
| - return type of generator is (&'1 i32, &i32)
The '1
lifetime name should be given to the second reference in the tuple.
@rustbot modify labels: C-bug A-async-await A-diagnostics A-lifetimes T-compiler
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsArea: Lifetimes / regionsAsync-await issues that have been triaged during a working group meeting.Category: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Done