Repository: rust
Issue: Bad diagnostics for erroneous use of array syntax around range in for
Labels: A-diagnostics,T-compiler

### Code

```Rust
fn main() {
    for a in [0..4] {
        println!("{a}");
        for b in a..4 {
            println!("{a} {b}");
        }
    }
}
```


### Current output

```Shell
fn main() {
    for a in [0..4] {
        println!("{a}");
        for b in a..4 {
            println!("{a} {b}");
        }
    }
}
⣿
Standard Error

   Compiling playground v0.0.1 (/playground)
error[E0277]: `std::ops::Range<{integer}>` doesn't implement `std::fmt::Display`
 --> src/main.rs:4:20
  |
4 |         println!("{a}");
  |                    ^ `std::ops::Range<{integer}>` cannot be formatted with the default formatter
  |
  = help: the trait `std::fmt::Display` is not implemented for `std::ops::Range<{integer}>`
  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
  = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:5:21
  |
5 |         for b in a..4 {
  |                     ^ expected struct `std::ops::Range`, found integer
  |
  = note: expected struct `std::ops::Range<{integer}>`
               found type `{integer}`

error[E0277]: the trait bound `std::ops::Range<{integer}>: Step` is not satisfied
 --> src/main.rs:5:18
  |
5 |         for b in a..4 {
  |                  ^^^^ the trait `Step` is not implemented for `std::ops::Range<{integer}>`
  |
  = help: the following other types implement trait `Step`:
            char
            i128
            i16
            i32
            i64
            i8
            isize
            u128
          and 5 others
  = note: required for `std::ops::Range<std::ops::Range<{integer}>>` to implement `Iterator`
  = note: required for `std::ops::Range<std::ops::Range<{integer}>>` to implement `IntoIterator`

error[E0277]: `std::ops::Range<{integer}>` doesn't implement `std::fmt::Display`
 --> src/main.rs:6:24
  |
6 |             println!("{a} {b}");
  |                        ^ `std::ops::Range<{integer}>` cannot be formatted with the default formatter
  |
  = help: the trait `std::fmt::Display` is not implemented for `std::ops::Range<{integer}>`
  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
  = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `std::ops::Range<{integer}>` doesn't implement `std::fmt::Display`
 --> src/main.rs:6:28
  |
6 |             println!("{a} {b}");
  |                            ^ `std::ops::Range<{integer}>` cannot be formatted with the default formatter
  |
  = help: the trait `std::fmt::Display` is not implemented for `std::ops::Range<{integer}>`
  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
  = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `playground` due to 5 previous errors

Standard Output
```


### Desired output

Ideally, the compiler would spot this situation and add some help output suggesting removing the `[ ]`.

### Rationale and extra context

In many languages `[a..b]` is how one spells a range iteration.  In Rust the `[ ]` are superfluous, and result in a one-element array, which when iterated over binds the loop variable to the range.

### Other cases

I think the trigger for the suggestion should be something like "type error involving a `Range` object which resulted from iterating over a single-element array.