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

Feature Request: Default to only formatting generated code if rustfmt is available #795

Closed
casey opened this issue Oct 18, 2021 · 1 comment

Comments

@casey
Copy link

casey commented Oct 18, 2021

Feature Request

Crates

  • tonic_build

Motivation

By using tonic_build with the default settings, we inadvertently added a build-time dependency on rustfmt, which was later noticed by a downstream packager, who requested we remove the dependency to avoid extra build-time dependencies.

Proposal

I would suggest that there be three options regarding formatting of generated code:

  1. Don't format generated code
  2. Always format generated code
  3. Only format generated code if rustfmt is available. (I.e. silently continue if launching rustfmt returns a not found error.)

And that 3 should be the default, since formatted code is nice and low-cost if rustfmt is available, but otherwise not important enough to fail a build.

Alternatives

We could do this ourselves in the build script, i.e. check at build-time for rustfmt and pass true or false to the format method of the builder accordingly. However, it seems like this would be a good default that other users of the crate would benefit from.

@tottoto
Copy link
Collaborator

tottoto commented Jun 5, 2024

Resolved in #904.

@tottoto tottoto closed this as completed Jun 5, 2024
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