Skip to main content

Module rustfmt

Module rustfmt 

Source

StructsΒ§

Group πŸ”’
A set of files to format together under a common edition.
Package πŸ”’
Metadata about one workspace package.
Rustfmt

ConstantsΒ§

MAX_FILE_ARG_BYTES πŸ”’
Windows caps a process’s command line at 32767 characters. Batches are normally kept far below this to spread work across threads; this is only a backstop for unusually long paths.
MIN_BATCH_FILES πŸ”’
Spawning rustfmt costs more than formatting a handful of files, so batches below this size are not worth the extra parallelism. Measured on this repo, one process per file is ~3x slower than batching.

FunctionsΒ§

batch_files πŸ”’
Split files into batches that fit in a command line and are small enough to spread across the available threads.
batch_size πŸ”’
Choose how many files to put in each batch: enough batches to keep every thread busy through the end of the run, but not so few files per batch that process startup dominates.
group_diffed πŸ”’
Group diffed files by the edition of the innermost package containing them, so that they are parsed the same way as in a full run.
group_roots πŸ”’
Group every package’s crate roots by edition. rustfmt walks mod declarations itself, so these roots transitively cover every file that cargo fmt would format.
run_rustfmt πŸ”’
Run rustfmt over each group, splitting the groups into batches that run in parallel.
workspace_packages πŸ”’
Collect the edition, directory, and crate roots of every workspace package.