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

Use prettyplease instead of rustfmt for generated code #2947

Closed
teh-cmc opened this issue Aug 9, 2023 · 0 comments · Fixed by #2949
Closed

Use prettyplease instead of rustfmt for generated code #2947

teh-cmc opened this issue Aug 9, 2023 · 0 comments · Fixed by #2949
Assignees
Labels
codegen/idl 🧑‍💻 dev experience developer experience (excluding CI)

Comments

@teh-cmc
Copy link
Member

teh-cmc commented Aug 9, 2023

rustfmt gives up on formatting past a certain threshold of code complexity, which is very easy to hit in generated code.

The recommended solution is to use https://github.com/dtolnay/prettyplease instead, but that would probably require some extra level of care so the two formatters don't end up fighting each other in practice.

@teh-cmc teh-cmc added 🧑‍💻 dev experience developer experience (excluding CI) codegen/idl labels Aug 9, 2023
@emilk emilk self-assigned this Aug 9, 2023
emilk added a commit that referenced this issue Aug 9, 2023
* Closes #2947

### What
Use [`prettyplease`](https://github.com/dtolnay/prettyplease ) to format
our generated Rust code, before also running `cargo fmt` on it. Yes, we
need both.

Example of the resulting improvement:


![image](https://github.com/rerun-io/rerun/assets/1148717/77b24ed7-8ac5-4e35-9918-c8cb7aa1c49a)


### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2949) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2949)
- [Docs
preview](https://rerun.io/preview/pr%3Aemilk%2Fprettyplease/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aemilk%2Fprettyplease/examples)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen/idl 🧑‍💻 dev experience developer experience (excluding CI)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants