Skip to content

Inconsistent formatting between functions and function-like macros #5029

Open
@newpavlov

Description

@newpavlov

Rustfmt accepts the following code without issues:

pub const FOO: &str = foo("
    foo
    bar
");

But if we are to replace foo with a function-like macro:

pub const FOO: &str = foo!("
    foo
    bar
");

Rustfmt wants to reformat it as:

pub const FOO: &str = foo!(
    "
    foo
    bar
"
);

The resulting formatting is far from beautiful, space inefficient, and inconsistent with how rustfmt handles functions.

This issue is quite annoying in practice for example when code uses the hex-literal crate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions