Skip to content

Rustfmt formats macro to exceed line length #2919

Closed
@YaLTeR

Description

@YaLTeR

I have this macro that I formatted manually:

        macro_rules! touch_value {
            ($func:ident, $value:expr) => {{
                let result =
                    API::get_cached().$func(
                        self,
                        key.as_ptr(),
                        $value,
                        ffi::VSPropAppendMode::paTouch
                    );
                debug_assert!(result == 0);
            }};
        }

Running rustfmt (or rustfmt --check) suggests the following diff:

         macro_rules! touch_value {
             ($func:ident, $value:expr) => {{
                 let result =
-                    API::get_cached().$func(
-                        self,
-                        key.as_ptr(),
-                        $value,
-                        ffi::VSPropAppendMode::paTouch
-                    );
+                    API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendMode::paTouch);
                 debug_assert!(result == 0);
             }};
         }

Which makes the line exceed the line length limit. Previously this also resulted in rustfmt complaining about it exceeding the line length limit (so basically it breaks the formatting and then complains about it).

While putting #[cfg_attr(rustfmt, rustfmt_skip)] ontop prevents the issue from happening, maybe rustfmt shouldn't reformat the macro in this case?

Update: rustfmt 0.99.2-nightly (5c9a2b6 2018-08-07) although this has been happening for several months (since that macro appeared in the codebase).

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