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 after the first one in empty struct are not formatted nicely #4854

Closed
wooster0 opened this issue May 28, 2021 · 1 comment · Fixed by #5171
Closed

Comments after the first one in empty struct are not formatted nicely #4854

wooster0 opened this issue May 28, 2021 · 1 comment · Fixed by #5171

Comments

@wooster0
Copy link
Contributor

struct Struct {
    // Hello, this is my
    // struct where I haven't added
    // any fields yet.
    // TODO: add fields
}

If you format this code, it becomes:

struct Struct {
    // Hello, this is my
// struct where I haven't added
// any fields yet.
// TODO: add fields
}

I expected it to stay the way it is because it already looks perfectly fine and leaving only the first comment indented looks odd.

@calebcartwright
Copy link
Member

Thanks for sharing! Seems to occur with other struct types
e.g.

struct Foo(
    // Bar
    // Baz
    // Qux
);

so probably a general indentation issue with empty struct defs

For anyone interested in working on this a good starting place to look in the code would probably be here:
https://github.com/rust-lang/rustfmt/blob/master/src/items.rs#L1040-L1055

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