Repository: rust
Issue: Confusing error message when forgetting semicolon after spawning a scoped thread
Labels: A-diagnostics,T-compiler

### Code

```Rust
use std::thread;

fn do_something(_data: &[u8]) {}

fn do_something_else(_data: &[u8]) {}

fn main() {
    let data: Vec<u8> = vec![];
    thread::scope(|scope| {
        scope.spawn(|| do_something(&data));
        scope.spawn(|| do_something_else(&data))
    });
    dbg!(data);
}
```


### Current output

```
error: lifetime may not live long enough
  --> src/main.rs:11:9
   |
9  |     thread::scope(|scope| {
   |                    ------ return type of closure is ScopedJoinHandle<'2, ()>
   |                    |
   |                    has type `&'1 Scope<'1, '_>`
10 |         scope.spawn(|| do_something(&data));
11 |         scope.spawn(|| do_something_else(&data))
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
   |
help: consider adding 'move' keyword before the nested closure
   |
11 |         scope.spawn(move || do_something_else(&data))
   |                     ++++
```


### Desired output

Ideally, a hint that it does not make sense to return `ScopedJoinHandle` from the argument of the `thread::scope` call (and maybe even a suggestion to add the missing semicolon). 

At the very least, the same output as now, but without the misleading "consider adding 'move' keyword before the nested closure", because it does not help and in fact makes the error even more confusing (see below)


### Rationale and extra context

_No response_

### Other cases

Adding a `move`, as suggested by the compiler output:


```Rust
use std::thread;

fn do_something(_data: &[u8]) {}

fn do_something_else(_data: &[u8]) {}

fn main() {
    let data: Vec<u8> = vec![];
    thread::scope(|scope| {
        scope.spawn(|| do_something(&data));
        scope.spawn(move || do_something_else(&data))
    });
    dbg!(data);
}
```
gives
```
error[E0373]: closure may outlive the current function, but it borrows `data`, which is owned by the current function
  --> src/main.rs:10:21
   |
9  |     thread::scope(|scope| {
   |                    ----- has type `&'1 Scope<'1, '_>`
10 |         scope.spawn(|| do_something(&data));
   |                     ^^               ---- `data` is borrowed here
   |                     |
   |                     may outlive borrowed value `data`
   |
note: function requires argument type to outlive `'1`
  --> src/main.rs:10:9
   |
10 |         scope.spawn(|| do_something(&data));
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to force the closure to take ownership of `data` (and any other referenced variables), use the `move` keyword
   |
10 |         scope.spawn(move || do_something(&data));
   |                     ++++

error: lifetime may not live long enough
  --> src/main.rs:11:9
   |
9  |     thread::scope(|scope| {
   |                    ------ return type of closure is ScopedJoinHandle<'2, ()>
   |                    |
   |                    has type `&'1 Scope<'1, '_>`
10 |         scope.spawn(|| do_something(&data));
11 |         scope.spawn(move || do_something_else(&data))
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`

error[E0505]: cannot move out of `data` because it is borrowed
  --> src/main.rs:11:21
   |
9  |     thread::scope(|scope| {
   |                    ----- has type `&'1 Scope<'1, '_>`
10 |         scope.spawn(|| do_something(&data));
   |         -----------------------------------
   |         |           |                |
   |         |           |                borrow occurs due to use in closure
   |         |           borrow of `data` occurs here
   |         argument requires that `data` is borrowed for `'1`
11 |         scope.spawn(move || do_something_else(&data))
   |                     ^^^^^^^                    ---- move occurs due to use in closure
   |                     |
   |                     move out of `data` occurs here

error[E0382]: use of moved value: `data`
  --> src/main.rs:13:10
   |
8  |     let data: Vec<u8> = vec![];
   |         ---- move occurs because `data` has type `Vec<u8>`, which does not implement the `Copy` trait
9  |     thread::scope(|scope| {
   |                   ------- value moved into closure here
10 |         scope.spawn(|| do_something(&data));
11 |         scope.spawn(move || do_something_else(&data))
   |                                                ---- variable moved due to use in closure
12 |     });
13 |     dbg!(data);
   |          ^^^^ value used here after move

Some errors have detailed explanations: E0373, E0382, E0505.
For more information about an error, try `rustc --explain E0373`.
```

### Anything else?

_No response_