Skip to content
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

Strange formatted comments behind if let in a new line #3979

Closed
CYBAI opened this issue Dec 24, 2019 · 1 comment · Fixed by #4055
Closed

Strange formatted comments behind if let in a new line #3979

CYBAI opened this issue Dec 24, 2019 · 1 comment · Fixed by #4055
Labels
1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release a-comments poor-formatting

Comments

@CYBAI
Copy link

CYBAI commented Dec 24, 2019

$ rustfmt --version
rustfmt 1.4.11-nightly (1838235 2019-12-03)

I'm not sure if this is duplicate with #3937 so filed this one.

Code:

fn main() {
    let o_num = Some(123);
    
    let x = if let Some(n) =
        // this is a test comment
        // to see if rustfmt will break
        // after using the lateset version
        o_num {
            n * 2
        } else {
            0
        };
    
    println!("Number: {}", x);
}

Actual Formatted:

fn main() {
    let o_num = Some(123);

    let x = if let Some(n) =
        // this is a test comment
    // to see if rustfmt will break
    // after using the lateset version
        o_num
    {
        n * 2
    } else {
        0
    };

    println!("Number: {}", x);
}

Personal Expected Formatted:

fn main() {
    let o_num = Some(123);

    let x = if let Some(n) =
        // this is a test comment
        // to see if rustfmt will break
        // after using the lateset version
        o_num
    {
        n * 2
    } else {
        0
    };

    println!("Number: {}", x);
}
@SimonSapin
Copy link

Per servo/servo#25371 it looks like this regressed in 33e3667...1838235

$ rustfmt +nightly-2019-12-05 -V
rustfmt 1.4.9-nightly (33e3667 2019-10-07)
$ rustfmt +nightly-2019-12-25 -V
rustfmt 1.4.11-nightly (1838235 2019-12-03)

@calebcartwright calebcartwright added the 1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release label Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release a-comments poor-formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants