-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2021Area: The 2021 editionArea: The 2021 editionT-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
Given the following code, compiled using Rust 2018 edition:
fn main() {
let mut x = ("a".to_string(), "b".to_string());
let mut f = || x.0 += "...";
x.1 += "...";
f();
}
The current output is:
error[E0499]: cannot borrow `x.1` as mutable more than once at a time
--> src/main.rs:4:5
|
3 | let mut f = || x.0 += "...";
| -- --- first borrow occurs due to use of `x` in closure
| |
| first mutable borrow occurs here
4 | x.1 += "...";
| ^^^ second mutable borrow occurs here
5 | f();
| - first borrow later used here
For more information about this error, try `rustc --explain E0499`.
Ideally the output should look include:
Note: disjoint capture is available in Rust 2021 edition; see https://doc.rust-lang.org/edition-guide/rust-2021/disjoint-capture-in-closures.html
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2021Area: The 2021 editionArea: The 2021 editionT-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.