about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-03 21:18:29 +0200
committerGitHub <noreply@github.com>2025-04-03 21:18:29 +0200
commit731ce84d19efa30700389caefe17c542050298c0 (patch)
tree1bb621b6418c4ea038a06e6deba49eb68a0f11f0 /compiler/rustc_codegen_llvm/src
parente5c7451a109974e056e95ea25ffe90613aa95057 (diff)
parent2d2307e6163816511790c3bb61e07913d9cb66c1 (diff)
downloadrust-731ce84d19efa30700389caefe17c542050298c0.tar.gz
rust-731ce84d19efa30700389caefe17c542050298c0.zip
Rollup merge of #138462 - ShE3py:mut-borrow-in-loop, r=oli-obk
Dedup `&mut *` reborrow suggestion in loops

#73534 added a reborrow suggestion in loops; #127579 generalized this to generic parameters, making the suggestion triggers twice:
```rs
use std::io::Read;

fn decode_scalar(_reader: impl Read) {}
fn decode_array(reader: &mut impl Read) {
    for _ in 0.. {
        decode_scalar(reader);
    }
}
```
```
error[E0382]: use of moved value: `reader`
 --> src/lib.rs:6:23
  |
4 | fn decode_array(reader: &mut impl Read) {
  |                 ------ move occurs because `reader` has type `&mut impl Read`, which does not implement the `Copy` trait
5 |     for _ in 0.. {
  |     ------------ inside of this loop
6 |         decode_scalar(reader);
  |                       ^^^^^^ value moved here, in previous iteration of loop
  |
help: consider creating a fresh reborrow of `reader` here
  |
6 |         decode_scalar(&mut *reader);
  |                       ++++++
help: consider creating a fresh reborrow of `reader` here
  |
6 |         decode_scalar(&mut *reader);
  |                       ++++++
```
This PR removes the suggestion in loops, as it requires generic parameters anyway (i.e., the reborrow is automatic if there is no generic params).

`@rustbot` label +A-borrow-checker +A-diagnostics +A-suggestion-diagnostics +D-papercut
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions