]> git.lizzy.rs Git - rust.git/commitdiff
Merge #9108
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Wed, 2 Jun 2021 17:25:11 +0000 (17:25 +0000)
committerGitHub <noreply@github.com>
Wed, 2 Jun 2021 17:25:11 +0000 (17:25 +0000)
9108: Don't show extract into variable assist for unit expressions r=jonas-schievink a=brandondong

**Reproduction:**

```rust
fn main() {
    let mut i = 3;
    $0if i >= 0 {
        i += 1;
    } else {
        i -= 1;
    }$0
}
```

1. Select the snippet of code between the $0's.
2. The extract into variable assist shows up, pushing down the more useful extract into function assist.
3. The resulting output of selecting the extract into variable assist is valid but with the extracted variable having the unit type:
```rust
fn main() {
    let mut i = 3;
    let var_name = if i >= 0 {
        i += 1;
    } else {
        i -= 1;
    };
    var_name
}
```

**Fix:**
- Don't show the extract into variable assist for unit expressions. I could not think of any scenarios where such a variable extraction would be desired.

Co-authored-by: Brandon <brandondong604@hotmail.com>

Trivial merge