Repository: rust
Issue: Suggest dropping before reassignment of a variable with a mutable reference and a destructor
Labels: A-diagnostics,T-compiler

### Code

```Rust
struct Bar<'num>(&'num mut i32);

impl Drop for Bar<'_> {
    fn drop(&mut self) {
    }
}

fn foo(mut_ref: &mut i32) {

    let mut baz = Bar(mut_ref);
    // drop(baz);
    baz = Bar(mut_ref);
}
```


### Current output

```Shell
warning: variable `baz` is assigned to, but never used
  --> src/main.rs:10:13
   |
10 |     let mut baz = Bar(mut_ref);
   |             ^^^
   |
   = note: consider using `_baz` instead
   = note: `#[warn(unused_variables)]` on by default

warning: value assigned to `baz` is never read
  --> src/main.rs:12:5
   |
12 |     baz = Bar(mut_ref);
   |     ^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

error[E0499]: cannot borrow `*mut_ref` as mutable more than once at a time
  --> src/main.rs:12:15
   |
10 |     let mut baz = Bar(mut_ref);
   |                       ------- first mutable borrow occurs here
11 |     // drop(baz);
12 |     baz = Bar(mut_ref);
   |     ---       ^^^^^^^ second mutable borrow occurs here
   |     |
   |     first borrow might be used here, when `baz` is dropped and runs the `Drop` code for type `Bar`

error: aborting due to 1 previous error; 2 warnings emitted

For more information about this error, try `rustc --explain E0499`.
```


### Desired output

```Shell
I have no idea how the diagnostic syntax is for suggesting a new item:

warning: variable `baz` is assigned to, but never used
  --> src/main.rs:10:13
   |
10 |     let mut baz = Bar(mut_ref);
   |             ^^^
   |
   = note: consider using `_baz` instead
   = note: `#[warn(unused_variables)]` on by default

warning: value assigned to `baz` is never read
  --> src/main.rs:12:5
   |
12 |     baz = Bar(mut_ref);
   |     ^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

error[E0499]: cannot borrow `*mut_ref` as mutable more than once at a time
  --> src/main.rs:12:15
   |
10 |     let mut baz = Bar(mut_ref);
   |                       ------- first mutable borrow occurs here
11 |     // drop(baz);
12 |     baz = Bar(mut_ref);
   |     ---       ^^^^^^^ second mutable borrow occurs here
   |     |
   |     first borrow might be used here, when `baz` is dropped and runs the `Drop` code for type `Bar`
   = help: try dropping before the assignment: `drop(baz);`

error: aborting due to 1 previous error; 2 warnings emitted

For more information about this error, try `rustc --explain E0499`.
```


### Rationale and extra context

When adding `drop(baz);` before the assignment the code works and at least to me, it's not immediately obvious that a drop would fix it or even work between assignments.

### Other cases

_No response_

### Rust Version

```Shell
$ rustc --version --verbose
rustc 1.77.2 (25ef9e3d8 2024-04-09) (built from a source tarball)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6
```


### Anything else?

_No response_