Skip to content

rustfmt is not idempotent and not consistent #4963

Closed
@datdenkikniet

Description

@datdenkikniet

When formatting the following code,

mod test {
    extern "C" {fn test();}
}

The first diff suggested by rustfmt is

-    extern "C" {fn test();}
+    extern "C" {
+        fn test();    }

After running this formatting, the next suggestion is

-        fn test();    }
+        fn test();
+    }

The final result seems to be correct, but should most likely be applied at once, not in two steps.

Additionally, removing the mod block causes the changes to look like this:

extern "C" {fn test();}
-extern "C" {fn test();}
+extern "C" {
+    fn test();}

This change is idempotent, but I would expect the closing } to be moved to the next line (which is what happens if a whitespace is put in between the final ; and }).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions