about summary refs log tree commit diff
path: root/src/test/ui/array-slice-vec/array_const_index-1.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-10-06 07:07:37 +0200
committerGitHub <noreply@github.com>2022-10-06 07:07:37 +0200
commit0512a06186916d097a1a1f8ae1210e1295cc1a1c (patch)
tree668f8419adaea2e455c8d62df20f7f8a570266f0 /src/test/ui/array-slice-vec/array_const_index-1.rs
parenta9b3441c178191b4d33f9fe6b8e937894baff7c4 (diff)
parentb7c42c55a2e64e77d4eced0ccd51b5f2603395a0 (diff)
downloadrust-0512a06186916d097a1a1f8ae1210e1295cc1a1c.tar.gz
rust-0512a06186916d097a1a1f8ae1210e1295cc1a1c.zip
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
Diffstat (limited to 'src/test/ui/array-slice-vec/array_const_index-1.rs')
0 files changed, 0 insertions, 0 deletions