Skip to content

Strange formatting of macro_rules! macro #6131

Open
@Andlon

Description

@Andlon

With Rust 1.77.1 and rustfmt 1.7.0, as well as on current nightly 2024-03-30, the following macro definition (playground)

macro_rules! assert_eq_and_type {
    ($left:expr, $right:expr $(,)?) => {
        {
            fn check_statically_same_type<T>(_: &T, _: &T) {}
            check_statically_same_type(&$left, &$right);
        }
        assert_eq!($left, $right);
    };
}

formats to

macro_rules! assert_eq_and_type {
    ($left:expr, $right:expr $(,)?) => {{
        fn check_statically_same_type<T>(_: &T, _: &T) {}
        check_statically_same_type(&$left, &$right);
    }
    assert_eq!($left, $right);};
}

This certainly doesn't look right to me. I looked at other reported macro-related issues but couldn't find any very similar issues.

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