spin icon indicating copy to clipboard operation
spin copied to clipboard

chore(rustfmt): standardize the order of Rust imports

Open radu-matei opened this issue 3 years ago • 6 comments

This commit updates the order of the Rust imports throughtout the project to be consistent with — specifically, standard library, external, and crate imports.

The group_imports=StdExternalCrate rustfmt setting only works for the nightly toolchain, so this commit does not enforce it in CI (which would also require all contributors to run the nightly toolchain to format).

To run the formatter using this setting:

cargo +nightly fmt --all -- --emit files --config group_imports=StdExternalCrate

Signed-off-by: Radu Matei [email protected]

radu-matei avatar May 10 '22 01:05 radu-matei

What is the expectation here for maintenance, given no CI and the nightly toolchain requirement? Is this something that we will do as and when the spirit moves us, or is it on contributors to keep it straight day by day?

itowlson avatar May 10 '22 02:05 itowlson

As you mentioned, because there is not way to enforce this without forcing contributors to use the nightly toolchain, I don't think it is reasonable to expect CI to break either, and given that we already have strict formatting rules for everything else, I would be ok with doing this as and when the spirit moves us.

We could add a Make target for running the nightly command above, if you think that helps.

radu-matei avatar May 10 '22 02:05 radu-matei

Nah, "as and when" was the arrangement I assumed and I'm happy with it. Thanks!

itowlson avatar May 10 '22 02:05 itowlson

I am a bit concenred that if we do not enforce this to CI and all developers, pr like this will generate lots of conflicts for local developing branches.

Mossaka avatar May 10 '22 05:05 Mossaka

Yeah, that can definitely happen. But that is the case with any large PR.

My hope is that when such PRs generate conflicts, you could run the the local formatting command:

$ cargo +nightly fmt --all -- --emit files --config group_imports=StdExternalCrate

But I get your concern here, not sure what the best way to address this.

radu-matei avatar May 10 '22 10:05 radu-matei

We can also do this incrementally as we are doing "major work" on individual crates/files. Until the config option is stable its going to drift over time anyway.

lann avatar May 13 '22 14:05 lann

Closing this for now. Once the formatter is stable, we could revisit this.

radu-matei avatar Aug 25 '22 23:08 radu-matei