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

Comments inside struct gets indented #4952

Closed
GrabbenD opened this issue Aug 11, 2021 · 1 comment
Closed

Comments inside struct gets indented #4952

GrabbenD opened this issue Aug 11, 2021 · 1 comment

Comments

@GrabbenD
Copy link

We have a particular struct that contains a lot of useful values and some are commented out for the time being. Each field has its own comment with a explanation for future reference. However, if a field is commented rustfmt adds indentation to get it inlined with the comment on the previous line. Here's a example:

// Preferred formatting
pub struct Example {
    pub one: String,     // Test
    pub two: bool,       // Test
    //pub three: String, // Test
    //pub four: bool,    // Test
}

// $ cargo fmt
pub struct Example {
    pub one: String, // Test
    pub two: bool,   // Test
                     //pub three: String, // Test
                     //pub four: String,  // Test
}

We're using default rustfmt v1.4.36 config and it doesn't seem like there is a way around this in stable channel? We've tried using /* */ around fields that are supposed to be commented out but it didn't work.

Is there anything we can do about this?

@calebcartwright
Copy link
Member

Thanks for reaching out but going to close as it's largely a duplicate of #4108. rustfmt is never supposed to do any visual/vertical alignment by default, but does in trailing cases like this on struct fields as well as enum variants and params in function signatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants