Skip to content

unwrap_block deleting too much #11049

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

Closed
Heinenen opened this issue Dec 18, 2021 · 0 comments
Closed

unwrap_block deleting too much #11049

Heinenen opened this issue Dec 18, 2021 · 0 comments
Labels
A-assists C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@Heinenen
Copy link
Contributor

When the code inside a block has only one line, using the unwrap_block function sometimes causes rust-analyzer to cut the beginning and end of the line.

Some examples that I tested:

fn unwrap() -> i32 {
    if 2 > 1 {$0
        return 3;
    }
    5
} // transforms into

fn unwrap() -> i32 {
    eturn$0
    5
}
fn unwrap() -> i32 {
    if 2 > 1 {$0
        3
    } else {
        5
    }
}
// throws error "server panicked: byte index 18446744073709551615 is out of bounds of ``"
fn unwrap() -> i32 {
    if 2 > 1 {$0
        println!("");
    }
    5
} // works as intended

fn unwrap() -> i32 {
    println!("$0");
    5
}

rust-analyzer version: db2a708 2021-12-13 stable

rustc version: 1.57.0 (f1edd0429 2021-11-29)

@lnicola lnicola added A-assists C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now labels Dec 18, 2021
@bors bors bot closed this as completed in 638cc3e Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

2 participants