Skip to content

Macro-generated structs/enums are not indented properly #4085

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

Closed
connorkuehl opened this issue Mar 17, 2020 · 3 comments
Closed

Macro-generated structs/enums are not indented properly #4085

connorkuehl opened this issue Mar 17, 2020 · 3 comments

Comments

@connorkuehl
Copy link

For example, this enum whose definition is supplemented by an enum, which is indented correctly:

enumerate! {
    pub enum IoctlCode: u32 {
        PlatformReset = 0,
        PlatformStatus = 1,
        PekGenerate = 2,
        PekCertificateSigningRequest = 3,
        PdhGenerate = 4,
        PdhCertificateExport = 5,
        PekCertificateImport = 6,
        GetIdentifier = 7,
    }
}

will be formatted like this after running cargo fmt:

enumerate! {
    pub enum IoctlCode: u32 {
    PlatformReset = 0,
    PlatformStatus = 1,
    PekGenerate = 2,
    PekCertificateSigningRequest = 3,
    PdhGenerate = 4,
    PdhCertificateExport = 5,
    PekCertificateImport = 6,
    GetIdentifier = 7,
    }
}

Here is enumerate!'s definition.

@connorkuehl
Copy link
Author

Okay, not sure if this is a bug at all. We determined it's because my editor was using tabs, not spaces, and cargo fmt was replacing the tabs with4 spaces but not performing any other work inside the block enclosed by the macro invocation.

@calebcartwright
Copy link
Member

We determined it's because my editor was using tabs, not spaces, and cargo fmt was replacing the tabs with4 spaces

Yup that'd do it. If you haven't seen it already, note you can leverage the hard_tabs config option to control that.

but not performing any other work inside the block enclosed by the macro invocation.

I'm not entirely clear what all other work inside the block would entail in the context of the snippet, but guessing you may be seeking something similar to #3445?

@connorkuehl
Copy link
Author

connorkuehl commented Mar 19, 2020

but not performing any other work inside the block enclosed by the macro invocation.

I'm not entirely clear what all other work inside the block would entail in the context of the snippet, but guessing you may be seeking something similar to #3445?

Yes, I think that issue you linked describes what indentation I'd expect to happen. Thank you! 😄

Duplicate of #3445.

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