Skip to content
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

rustfmt is not idempotent and not consistent #4963

Closed
datdenkikniet opened this issue Aug 23, 2021 · 1 comment · Fixed by #4982
Closed

rustfmt is not idempotent and not consistent #4963

datdenkikniet opened this issue Aug 23, 2021 · 1 comment · Fixed by #4982
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@datdenkikniet
Copy link

datdenkikniet commented Aug 23, 2021

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 }).

@calebcartwright calebcartwright added the bug Panic, non-idempotency, invalid code, etc. label Sep 8, 2021
@calebcartwright
Copy link
Member

Thanks for the report, this is definitely a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants