-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Merged by Bors] - rustfmt groups imports #660
Conversation
looks good imo as it helps with consistency and readability.
that's not perfect, but more like a minor inconvenience.
it's anyway more clear to use |
aa782ed
to
45a82b1
Compare
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.
lgtm
bors merge |
This enables the `group_imports` option. With this rustfmt automatically groups the imports in `std`, `external`, and `crate. This is almost what we already wanted but we lose control of some things: * it is not able to differentiate between workspace and external so all our crates will go in that section, * it does not understand local import: ```rust mod foo { struct Foo; } use foo::Foo; use rand::random; ``` instead of having a separate group for `foo`. * It does not respect groups that we create manually ```rust use tokio; use itertools; ``` the imports will be merged. Looking at the changeset we are not too bad at maintaining this style. Most of the changes are the position of `crate` wr.t. to `self` or `super`, fusing groups, and moving our workspace crates to the external one. But this will be our only option to enforce this style with a tool. https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#group_imports rust-lang/rustfmt#4709 rust-lang/rustfmt#4693
Pull request successfully merged into main. Build succeeded: |
This enables the
group_imports
option. With this rustfmt automatically groups the imports instd
,external
, and `crate.This is almost what we already wanted but we lose control of some things:
instead of having a separate group for
foo
.the imports will be merged.
Looking at the changeset we are not too bad at maintaining this style. Most of the changes are the position of
crate
wr.t. toself
orsuper
, fusing groups, and moving our workspace crates to the external one.But this will be our only option to enforce this style with a tool.
https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#group_imports
rust-lang/rustfmt#4709
rust-lang/rustfmt#4693