Skip to content

Don't show extract into variable assist for unit expressions #9108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2021

Conversation

brandondong
Copy link

Reproduction:

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:
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.

@jonas-schievink
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 2, 2021

@bors bors bot merged commit 5be653d into rust-lang:master Jun 2, 2021
@brandondong brandondong deleted the extract_variable_tuple branch June 2, 2021 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants