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
Update rustfmt #9669
Update rustfmt #9669
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should change default formatting settings.
Most rust code that exists will use the default settings. This is great because it means a lot of rust code has consistent style.
For example, the following projects do not change these settings
- rust standard library https://github.com/rust-lang/rust/blob/master/rustfmt.toml
- linux https://github.com/torvalds/linux/blob/e67572cd2204894179d89bd7b984072f19313b03/rust/alloc/boxed.rs
- tokio asynchronous runtime https://github.com/tokio-rs/tokio/
I agree in general however in this case - with the import style - we have inconsistent usage throughout the codebase. I believe that the addition of these style rules will improve code consistency within our codebase in a way that remains congruent with the styling and conventions used broadly by the Rust community. |
Apart from causing loads of merge conflicts, this is also not being enforced with the current setup
because we have it set to stable Line 1 in 3ff10bc
|
This PR adds
to the Rustfmt.
https://rust-lang.github.io/rustfmt/?version=v1.7.0&search=imports_granularity#imports_granularity
https://rust-lang.github.io/rustfmt/?version=v1.7.0&search=#group_imports
This will change Rust imports so that they are split into individual line items that are grouped (in order) as
std
,extern
andcrate
example:
becomes
The import groupings rule enforces the import grouping convention used by the Rust community whist the import granularity rule makes it easier to read/tidy-up Rust imports and makes it easier to see changes in PRs
Most of the code changes are the formatting rules being applied.
Notable changes in the PR are:
An example case where the applied rule improves readability