Skip to content

Run rustfmt on the emitted bindings #900

@fitzgen

Description

@fitzgen

Usually, we generate code that is fairly readable.

This is not always the case, and will often not be the case once --impl-debug lands: https://github.com/rust-lang-nursery/rust-bindgen/pull/899/files#diff-a1db39afd224d69f0732cc221a7430b8R32

We should run rustfmt on the code we emit to give it a consistent, pretty, and readable formatting.

While rustfmt does have a programmatic API, it is using libsyntax from the compiler's internals. This means it is nightly only.

So maybe we want to avoid using rustfmt as a library, and just invoke the rustfmt on the $PATH, if any? If we do this, we should pin the version of rustfmt we use with our test expectations, so that our tests don't break when new versions of rustfmt are published, or when contributors are using different versions of rustfmt.

cc @nrc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions