mirror of
https://github.com/rust-lang/rust
synced 2024-10-01 06:14:33 +00:00
![Esteban Küber](/assets/img/avatar_default.png)
``` error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/suggest-split-at-mut.rs:13:18 | LL | let a = &mut foo[..2]; | --- first mutable borrow occurs here LL | let b = &mut foo[2..]; | ^^^ second mutable borrow occurs here LL | a[0] = 5; | ---- first borrow later used here | = help: use `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices ``` Address most of #58792. For follow up work, we should emit a structured suggestion for cases where we can identify the exact `let (a, b) = foo.split_at_mut(2);` call that is needed.
29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
error[E0499]: cannot borrow `foo[_]` as mutable more than once at a time
|
|
--> $DIR/suggest-split-at-mut.rs:4:13
|
|
|
|
|
LL | let a = &mut foo[2];
|
|
| ----------- first mutable borrow occurs here
|
|
LL | let b = &mut foo[3];
|
|
| ^^^^^^^^^^^ second mutable borrow occurs here
|
|
LL | *a = 5;
|
|
| ------ first borrow later used here
|
|
|
|
|
= help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices
|
|
= help: consider using `.swap(index_1, index_2)` to swap elements at the specified indices
|
|
|
|
error[E0499]: cannot borrow `foo` as mutable more than once at a time
|
|
--> $DIR/suggest-split-at-mut.rs:13:18
|
|
|
|
|
LL | let a = &mut foo[..2];
|
|
| --- first mutable borrow occurs here
|
|
LL | let b = &mut foo[2..];
|
|
| ^^^ second mutable borrow occurs here
|
|
LL | a[0] = 5;
|
|
| ---- first borrow later used here
|
|
|
|
|
= help: use `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0499`.
|