rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Formatting of "block" macros in let assignments

Open slyrz opened this issue 9 years ago • 2 comments

I call some macros with curly braces and pretend they are blocks. In let assignments, rustfmt turns these macros from

fn main() {
    let x = {
        a();
        b();
        c()
    };
    let y = something!{
        a();
        b();
        c()
    };
}

into

fn main() {
    let x = {
        a();
        b();
        c()
    };
    let y =
        something!{
        a();
        b();
        c()
    };
}

I think it would look better if the macro names were kept on the same line as the let statement, similar to the formatting of real code blocks.

Here's a Playground link of the above example.

slyrz avatar Aug 14 '17 09:08 slyrz

Could you tell us which version you are using please? I think this is fixed on the latest rustfmt-nightly.

topecongiro avatar Aug 14 '17 15:08 topecongiro

Oh wow, that's embarrassing. I thought I was running rustfmt from git, but it was just the latest published version on crates.io. Current master branch has this issue fixed. Sorry for wasting your time.

slyrz avatar Aug 14 '17 16:08 slyrz