Files
rust/compiler
Matthias Krüger 0512a06186 Rollup merge of #102708 - TaKO8Ki:improve-eqeq-suggestion, r=estebank
Suggest `==` to wrong assign expr

Given the following code:

```rust
fn main() {
    let x = 3;
    let y = 3;
    if x == x && y = y {
        println!("{}", x);
    }
}
```

Current output is:

```
error[E0308]: mismatched types
 --> src/main.rs:4:18
  |
4 |     if x == x && y = y {
  |                  ^ expected `bool`, found integer

error[E0308]: mismatched types
 --> src/main.rs:4:8
  |
4 |     if x == x && y = y {
  |        ^^^^^^^^^^^^^^^ expected `bool`, found `()`
```

This adds a suggestion:

```diff
error[E0308]: mismatched types
 --> src/main.rs:6:18
  |
6 |     if x == x && y = y {
  |                  ^ expected `bool`, found integer

error[E0308]: mismatched types
 --> src/main.rs:6:8
  |
6 |     if x == x && y = y {
  |        ^^^^^^^^^^^^^^^ expected `bool`, found `()`
  |
+ help: you might have meant to compare for equality
+   |
+ 6 |     if x == x && y == y {
+   |                     +
```

And this fixes a part of #97469
2022-10-06 07:07:37 +02:00
..
2022-10-03 11:42:29 +11:00
2022-09-26 10:14:45 +02:00
2022-09-29 08:44:52 +10:00
2022-09-26 10:14:45 +02:00
2022-09-30 21:02:53 +02:00
2022-09-26 10:14:45 +02:00
2022-09-29 08:44:52 +10:00
2022-09-29 08:44:52 +10:00
2022-09-26 10:14:45 +02:00