Repository: rust
Issue: Bad diagnostic help when calling a flatten on an owned type, advises to use infinite borrows
Labels: A-diagnostics,T-compiler

### Code

```Rust
use std::sync::mpsc::channel;

struct TimestampedList {
    lines: Vec<u8>,
    timestamps: Vec<u64>,
}

impl<'a> IntoIterator for &'a TimestampedList {
    type Item = (&'a [u8], &'a u64);
    type IntoIter = std::iter::Zip<
        std::slice::SplitInclusive<'a, u8, fn(&u8) -> bool>,
        std::slice::Iter<'a, u64>,
    >;

    fn into_iter(self) -> Self::IntoIter {
        self.lines
            .split_inclusive((|x| {*x == b'\n'}) as fn(&u8) -> bool)
            .zip(&self.timestamps)
    }
}

fn main() {
    let (_, r) = channel::<TimestampedList>();
    r.iter().flatten();
    // I can add as many as I want and it won't solve the issue
    &(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&r)))))))))))))))).iter().flatten();
}
```


### Current output

```Shell
Compiling playground v0.0.1 (/playground)
error[E0277]: `TimestampedList` is not an iterator
  --> src/main.rs:24:14
   |
24 |     r.iter().flatten();
   |              ^^^^^^^ the trait `IntoIterator` is not implemented for `TimestampedList`
   |
   = note: the trait bound `TimestampedList: IntoIterator` is not satisfied
   = note: required for `TimestampedList` to implement `IntoIterator`
note: required by a bound in `flatten`
  --> /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/iter/traits/iterator.rs:1587:5
help: consider borrowing here
   |
24 |     (&r.iter()).flatten();
   |     ++        +

error[E0277]: `TimestampedList` is not an iterator
  --> src/main.rs:26:63
   |
26 |     &(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&r)))))))))))))))).iter().flatten();
   |                                                               ^^^^^^^ the trait `IntoIterator` is not implemented for `TimestampedList`
   |
   = note: the trait bound `TimestampedList: IntoIterator` is not satisfied
   = note: required for `TimestampedList` to implement `IntoIterator`
note: required by a bound in `flatten`
  --> /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/iter/traits/iterator.rs:1587:5
help: consider borrowing here
   |
26 |     &(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&r)))))))))))))))).iter()).flatten();
   |      ++                                                        +

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 2 previous errors
```


### Desired output

```Shell
Compiling playground v0.0.1 (/playground)
error[E0277]: `TimestampedList` is not an iterator
  --> src/main.rs:24:14
   |
24 |     r.iter().flatten();
   |              ^^^^^^^ the trait `IntoIterator` is not implemented for `TimestampedList`
   |
   = note: the trait bound `TimestampedList: IntoIterator` is not satisfied
   = note: required for `TimestampedList` to implement `IntoIterator`
note: required by a bound in `flatten`
  --> /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/iter/traits/iterator.rs:1587:5
error[E0277]: `TimestampedList` is not an iterator
  --> src/main.rs:26:63
   |
26 |     &(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&r)))))))))))))))).iter().flatten();
   |                                                               ^^^^^^^ the trait `IntoIterator` is not implemented for `TimestampedList`
   |
   = note: the trait bound `TimestampedList: IntoIterator` is not satisfied
   = note: required for `TimestampedList` to implement `IntoIterator`
note: required by a bound in `flatten`
  --> /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/iter/traits/iterator.rs:1587:5

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 2 previous errors
```


### Rationale and extra context

The compiler proposes to borrow the receiver in the code, yet borrowing it does nothing. As such the compiler advises to borrow again and again ad infinitum. This is not helpful.

### Other cases

_No response_

### Anything else?

_No response_