about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/example/std_example.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-04-24 01:26:32 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-04-25 16:55:32 +0000
commit386236f289bad37370989866930be95b9067d07f (patch)
tree6cf97793d19e16a90680697077fac9b128260628 /compiler/rustc_codegen_gcc/example/std_example.rs
parent6a9758d4f38d4763bd437c48fa7e5246cecf8d04 (diff)
downloadrust-386236f289bad37370989866930be95b9067d07f.tar.gz
rust-386236f289bad37370989866930be95b9067d07f.zip
Detect borrow error involving sub-slices and suggest `split_at_mut`
```
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.
Diffstat (limited to 'compiler/rustc_codegen_gcc/example/std_example.rs')
0 files changed, 0 insertions, 0 deletions