Skip to content

Trailing comma is not added in macro invocation #4490

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
camelid opened this issue Oct 24, 2020 · 2 comments
Closed

Trailing comma is not added in macro invocation #4490

camelid opened this issue Oct 24, 2020 · 2 comments
Assignees

Comments

@camelid
Copy link
Member

camelid commented Oct 24, 2020

Perhaps this is intentional, but it is kind of frustrating so I thought I would report it.

Input

fn main() {
    let x = format!("hello, this is a long {} with {} format {}", "message", 2, "arguments");
    println!("{}", x);
}

Output

fn main() {
    let x = format!(
        "hello, this is a long {} with {} format {}",
        "message", 2, "arguments"
    );
    println!("{}", x);
}

Expected output

fn main() {
    let x = format!(
        "hello, this is a long {} with {} format {}",
        "message", 2, "arguments",
    );
    println!("{}", x);
}

(Note the trailing comma in the expected output that does not appear in the actual output.)

Meta

  • rustfmt version: 1.4.22-nightly (2020-10-04 97d0301) [on the playground]
  • From where did you install rustfmt?: on the playground
@camelid camelid changed the title Rustfmt doesn't add trailing commas in macro invocations Trailing comma is not added in macro invocation Oct 24, 2020
@calebcartwright
Copy link
Member

This is indeed by design currently (#3065). At some point down the road we may introduce some additional special case handling for macros where we know this could always be done without issue, but for now rustfmt has to defer to the user in these cases

@calebcartwright
Copy link
Member

Going to close in favor of #3065 as it has a more complete context on current state and possible future state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants