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

normalize_comments = true de-normalizes some comments #4909

Closed
drahnr opened this issue Jul 19, 2021 · 3 comments · Fixed by #5091
Closed

normalize_comments = true de-normalizes some comments #4909

drahnr opened this issue Jul 19, 2021 · 3 comments · Fixed by #5091
Labels
a-comments help wanted only-with-option requires a non-default option value to reproduce

Comments

@drahnr
Copy link

drahnr commented Jul 19, 2021

According to https://rust-lang.github.io/rustfmt/?version=v1.4.36&search=#normalize_comments should convert /* yada */ to // yada, but the inverse happens.

# rustfmt +nightly --version
rustfmt 1.4.37-nightly (d2b04f0 2021-07-07)
normalize_comments = true
normalize_doc_attributes = true

results in a delta of

@@ -150,11 +151,11 @@ pub enum Stage {
        AvailabilityRecovery = 6,
        BitfieldDistribution = 7,
        ApprovalChecking = 8,
-       // Expand as needed, numbers should be ascending according to the stage
-       // through the inclusion pipeline, or according to the descriptions
-       // in [the path of a para chain block]
-       // (https://polkadot.network/the-path-of-a-parachain-block/)
-       // see [issue](https://github.com/paritytech/polkadot/issues/2389)
+       /* Expand as needed, numbers should be ascending according to the stage
+        * through the inclusion pipeline, or according to the descriptions
+        * in [the path of a para chain block]
+        * (https://polkadot.network/the-path-of-a-parachain-block/)
+        * see [issue](https://github.com/paritytech/polkadot/issues/2389) */
 }
 
 /// A wrapper type for a span.
drahnr added a commit to paritytech/polkadot that referenced this issue Jul 19, 2021
* feat: rustfmt.toml

Copied from substrate.

* avoid normalize

It has some odd side effects converting // to /* */ instead of the other way round. See rust-lang/rustfmt#4909 .
@calebcartwright calebcartwright added a-comments help wanted only-with-option requires a non-default option value to reproduce labels Jul 21, 2021
@calebcartwright
Copy link
Member

Thanks for the report. This is technically a duplicate of a similar report added in a comment in #3350, but better to have a dedicated issue for it any way

@jplatte
Copy link

jplatte commented Sep 27, 2021

I just hit this when commenting out a field in a struct definition, but I haven't even set normalize_comments = true.

rustfmt --version: 1.4.37-nightly (5ecc8ad 2021-09-19)

.rustfmt.toml:

comment_width = 100
imports_granularity = "Crate"
newline_style = "Unix"
use_small_heuristics = "Max"
wrap_comments = true

@awused
Copy link

awused commented Oct 13, 2021

I'm also seeing this, regardless of the setting it converts a series of line comments to one block comment, with no ability to disable it. It's very annoying since I commonly comment and uncomment lines (say, benchmarks or parts of tests as I'm working on things) using a vim extension but it doesn't properly work with block comments. Rust is the only language where the formatter gets in the way like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments help wanted only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants