style: reformat imports granularity to module

Choosing module granularity over item granularity is based on a similar
choice made in the standard library to balance readabilty, with easy to
read diffs.

This saves 2098 lines or about 33% of the lines spent writing imports.
This is beneficial to both human readers who have to scroll past large
import blocks when reading a file as well as codex which shouldn't have
to add as many tokens to its context.

Manual changes to rustfmt.toml, rust-ci.yml, justfile, docs/contributing
and docs/install. The actual format commit is intentionally in a second
commit to make it easier to rebase this PR as main moves (drop the
next commit and re-run cargo +nightly fmt).

Added cargo nightly to the ci and justfile. In theory this is unstable,
but in real world use this tends to hit a problems perhaps once every
6 months. The fix is usually fairly easy (pin a version briefly), and
the problems tend to be fixed pretty quickly.
This commit is contained in:
Josh McKinney
2025-11-05 17:33:16 -08:00
parent 229d18f4d2
commit c67908ba17
5 changed files with 18 additions and 8 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ If you want to add a new feature or change the behavior of an existing one, plea
### Opening a pull request
- Fill in the PR template (or include similar information) - **What? Why? How?**
- Run **all** checks locally (`cargo test && cargo clippy --tests && cargo fmt -- --config imports_granularity=Item`). CI failures that could have been caught locally slow down the process.
- Run **all** checks locally (`cargo test && cargo clippy --tests && cargo +nightly fmt`). CI failures that could have been caught locally slow down the process.
- Make sure your branch is up-to-date with `main` and that you have resolved merge conflicts.
- Mark the PR as **Ready for review** only when you believe it is in a merge-able state.
+2 -1
View File
@@ -24,6 +24,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup component add rustfmt
rustup component add clippy
rustup install nightly # For rustfmt with unstable options.
# Build Codex.
cargo build
@@ -32,7 +33,7 @@ cargo build
cargo run --bin codex -- "explain this codebase to me"
# After making changes, ensure the code is clean.
cargo fmt -- --config imports_granularity=Item
cargo +nightly fmt
cargo clippy --tests
# Run the tests.