-
Notifications
You must be signed in to change notification settings - Fork 13.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 / regionsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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
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
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.
Type
Projects
Status
Done