Skip to content

Add test for issue #12552 #15235

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 28, 2014
Merged

Add test for issue #12552 #15235

merged 1 commit into from
Jun 28, 2014

Conversation

Sawyer47
Copy link
Contributor

Closes #12552

bors added a commit that referenced this pull request Jun 28, 2014
@bors bors closed this Jun 28, 2014
@bors bors merged commit 5be8409 into rust-lang:master Jun 28, 2014
@Sawyer47 Sawyer47 deleted the issue-12552 branch June 28, 2014 11:20
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2023
Stop inserting semicolon when extracting match arm

# Overview

Extracting a match arm value that has type unit into a function, when a
comma already follows the match arm value, results in an invalid (syntax
error) semicolon added between the newly generated function's generated
call and the comma.

# Example

Running this extraction

```rust
fn main() {
    match () {
        _ => $0()$0,
    };
}
```

would lead to

```rust
fn main() {
    match () {
        _ => fun_name();,
    };
}

fn fun_name() {
}
```

# Issue / Fix details

This happens because when there is no comma, rust-analyzer would simply
add the comma and wouldn't even try to evaluate whether it needs to add
a semicolon. But when the comma is there, it proceeds to evaluate
whether it needs to add a semicolon and it looks like the evaluation
logic erroneously ignores the possibility that we're in a match arm.
IIUC it never makes sense to add a semicolon when we're extracting from
a match arm value, so I've adjusted the logic to always decide against
adding a semicolon when we're in a match arm
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.

Index out of bounds @ vtable.rs:25
3 participants