Skip to content
CAI
Software that uses CAICheck a score

rust-lang/rustfmt

63.4

Adequate · 14 November 2026

34k

lines of production code

Rust

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add git-rustfmt utility for formatting Git history

A new \git-rustfmt\ tool is introduced to format Rust code across a specified number of recent Git commits. It integrates with the \rustfmt\_nightly\ library to apply formatting changes and uses the \tracing\ crate for logging, which is configured via the \RUSTFMT\_LOG\ environment variable. The tool supports a \-u\ flag to format uncommitted files and includes logic to prune \mod.rs\/\lib.rs\ files to avoid redundant formatting.

src/git-rustfmt · high confidence

Initial project scaffolding and documentation

The repository has been initialized with core project files, including the Apache 2.0 and MIT licenses, a Code of Conduct, and a design document outlining the tool's architecture. Comprehensive documentation has been added, including a configuration guide detailing available formatting options, a contributing guide with setup and testing instructions, and a README with quick-start and usage information. Additionally, standard development configuration files such as \.editorconfig\, \.gitattributes\, and \.gitignore\ have been created to enforce consistent coding standards and manage version control.

(repo-wide) · high confidence

Introduce \`cargo-fmt\` as a standalone binary with new CLI options

This change adds a new \src/cargo-fmt/main.rs\ file, creating a standalone \cargo fmt\ command-line tool. Users can now use flags such as \--check\ to verify formatting without modifying files, \--package\ (or \-p\) to target specific packages, and \--manifest-path\ to specify a custom \Cargo.toml\. The tool also respects the \RUSTFMT\ environment variable to locate the formatter and supports \--message-format\ for output styling. It replaces the previous internal implementation with a new structure using \clap\ for argument parsing.

src/cargo-fmt · high confidence

Introduce \`config\_type\` procedural macro for configuration enums

The new \config\_proc\_macro\ crate provides a \\#\[config\_type\]\ attribute that automatically implements \Display\, \FromStr\, \Serialize\, and \ConfigType\ traits for enums. This allows configuration options defined as enums to be parsed from strings, serialized to strings, and exposed via documentation hints, while supporting \doc\_hint\, \value\, and \unstable\_variant\ attributes to customize behavior and stability.

_config\_proc\macro/src · high confidence

Introduce check\_diff CLI tool for comparing rustfmt formatting outputs

Adds a new \check\_diff\ crate and CLI binary that compiles a specified rustfmt fork (source) against the latest main rustfmt (target) and compares their formatting results across a curated set of Rust ecosystem repositories. Users can configure the comparison via CLI arguments, including the source repository URL, feature branch, Rust edition, style edition, release channel (stable, beta, nightly), specific commit hash, custom rustfmt config options, and the number of worker threads for parallel checking. The tool clones the necessary repositories, builds both rustfmt versions, runs the formatter on each file, and reports any formatting diffs found, exiting with failure if differences are detected.

_check\diff/src · high confidence

Introduce rustfmt-format-diff utility for selective code formatting

A new \src/format-diff\ tool has been added to allow users to format only specific ranges within files based on a git diff. The utility reads a diff from standard input, identifies the affected files and line ranges, and invokes \rustfmt\ with the \--file-lines\ argument to apply formatting selectively. Users can control which files are processed using a custom regex filter (defaulting to \\*.rs\) and adjust path prefix skipping via the \-p\ flag. Logging is controlled via the \RUSTFMT\_LOG\ environment variable, and the specific \rustfmt\ binary to use can be specified via the \RUSTFMT\ environment variable.

src/format-diff · high confidence

New structured output emitters for CI and integration

The emitter module now includes dedicated output formats for machine-readable reporting and CI integration. A new Checkstyle emitter produces XML output compliant with the Checkstyle format, allowing integration with static analysis tools. A JSON emitter outputs structured data listing misformatted files and their specific line mismatches, enabling programmatic consumption of formatting results. Additionally, a ModifiedLines emitter provides a compact text representation of changes, and the existing Diff and Files emitters have been refined to better handle newline style conflicts and file writing with backups.

src/emitter · high confidence

Behavioural changes

CI scripts rewritten in Rust with new linting and integration checks

The CI automation scripts (previously shell-based) have been rewritten in Rust, introducing three new command-line tools: \build-and-test\ (which enforces \-D warnings\ via RUSTFLAGS and runs builds/tests with \--locked\), \clippy-config-check\ (which verifies that Clippy lint configurations are consistent across all Cargo.toml files), and \integration\ (which clones external repositories like cargo, crater, and bitflags to verify formatting and test stability). This change replaces the previous shell-based CI execution model with a structured Rust binary, ensuring stricter linting consistency and more robust integration testing.

ci · high confidence

Config system refactored to support Style Edition defaults

The configuration system has been restructured to allow formatting options to have different default values depending on the selected Style Edition (e.g., 2015, 2024, 2027). This is achieved by introducing a \StyleEditionDefault\ trait and a \style\_edition\_default!\ macro that map config options to edition-specific values, and by updating the \Config\ struct and its setter methods to resolve these defaults during initialization. This change enables the tool to apply edition-aware formatting rules automatically without requiring users to manually override every option.

src/config · high confidence

Improved parsing for cfg\_select!, cfg\_if!, lazy\_static!, and asm! macros

Rustfmt now includes dedicated parsers for several common macros, allowing it to understand and correctly format their internal structure. Specifically, it can now parse \cfg\_select!\ arms to discover modules defined within conditional compilation blocks, handle \cfg\_if!\ blocks to resolve module paths, format \lazy\_static!\ declarations, and process \asm!\ arguments. This change prevents infinite loops during \cfg\_select!\ parsing and ensures that items inside these macros are formatted consistently with the rest of the codebase.

src/parse/macros · high confidence

Parser module restructured with new session and builder patterns

The \src/parse\ module has been reorganized into \mod.rs\, \parser.rs\, and \session.rs\. The parser now uses a \ParserBuilder\ to construct \Parser\ instances, enforcing required inputs like \ParseSess\ and \Input\. A new \ParseSess\ wrapper manages the underlying rustc parse session, error handling via \SilentOnIgnoredFilesEmitter\, and module resolution logic, including a fallback to \dir\_path\ when relative external module resolution fails.

src/parse · high confidence

Refactor doc comment formatting logic

The logic for formatting doc comments has been refactored to use a new \DocCommentFormatter\ struct that processes string literals directly instead of using \Symbol\ values. This change improves the handling of multi-line doc attributes and ensures that empty doc attributes (\\#\[doc = ""\]\) are normalized correctly by inserting an empty line. The implementation now uses \peek()\ for safer iteration over lines, preserving whitespace within lines while correctly applying comment style openers.

src/attr · high confidence

Refined formatting heuristics and configuration options

The formatter now applies updated heuristics for chain breaking, function argument layout, and where clause placement, allowing for more compact or block-style formatting depending on line width and specific config settings. New configuration options such as \short\_item\_threshold\, \struct\_field\_align\_threshold\, and \imports\_granularity\ give users finer control over import grouping, struct field alignment, and item layout. Several legacy options have been renamed or removed (e.g., \fn\_args\_layout\ to \fn\_params\_layout\, \merge\_imports\ to \imports\_granularity\), and the tool now better handles comments, trailing commas, and edge cases in macros and type aliases to improve idempotence and output quality.

src · high confidence

Rustfmt binary rewritten with modern CLI and logging

The rustfmt command-line interface has been significantly restructured to improve usability and reliability. It now uses the \tracing\ ecosystem for logging, controlled via the \RUSTFMT\_LOG\ environment variable, replacing previous logging mechanisms. The CLI options have been consolidated and renamed: \--write-mode\ is replaced by \--emit\ (supporting modes like \files\, \stdout\, \coverage\, \checkstyle\, and \json\), and \--dump-default-config\/\--dump-minimal-config\ are replaced by \--print-config\ (supporting \default\, \minimal\, and \current\). A new \--check\ flag allows users to verify formatting without modifying files, exiting with code 1 if changes are needed. The \--style-edition\ option is now stable and allows specifying the style guide version (e.g., 2024). Additionally, \--backup\ is available to backup modified files, and \--files-with-diff\ (or \-l\) lists files that would be formatted. Error handling has been rationalized using \thiserror\, and the binary now exits with code 1 for license check failures in \--check\ mode and for general errors.

src/bin · high confidence

Support for @generated markers and improved Windows newline handling

Users can now skip formatting for files containing the \@generated\ marker by setting the new \generated\_marker\_line\_search\_limit\ configuration option, which controls how many lines are scanned for the marker. Additionally, the tool now more reliably detects and preserves Windows-style line endings (CRLF) in input files, including those with multibyte characters, and ensures that standalone carriage returns are handled correctly during conversion.

src/formatting · high confidence

Support for module discovery inside cfg\_if and cfg\_select macros

The module visitor now traverses \cfg\_if!\ and \cfg\_select!\ macro calls to discover nested module declarations, ensuring that modules defined within these conditional compilation blocks are correctly identified. Additionally, the \PathVisitor\ has been updated to handle Windows-specific path separators when extracting \path\ attributes from macro items.

src/modules · high confidence

Test coverage

1 commit adding/updating tests in tests/source/issue-5391; 1 commit adding/updating tests in tests/source/issue-6339; 1 commit adding/updating tests in tests/source/where-clause; 10 commits adding/updating tests in tests/target/cfg\_select; 2 commits adding/updating tests in tests/source/issue-6612; 2 commits adding/updating tests in tests/target/issue-5391; 2 commits adding/updating tests in tests/target/issue-6339; 2 commits adding/updating tests in tests/target/where-clause; 3 commits adding/updating tests in tests/target/issue-6612; 8 commits adding/updating tests in tests/source/cfg\_select; Add tests for postfix-match syntax formatting; Added baseline tests for macro body width formatting; Added configuration option tests for rustfmt; Added configuration tests for brace styles and wildcard suffix condensing; Added idempotence and style-edition tests for single-line function formatting; Added idempotence test for non-mod.rs submodules; Added idempotence tests for loop and while formatting across Rust editions; Added import formatting tests; Added integration tests for cargo-fmt; Added integration tests for config discovery with rustfmt settings; Added integration tests for rustfmt command-line options; Added parser regression test for issue 4126; Added parser regression tests for stashed diagnostics and try-macro chaining; Added parser test for unclosed delimiters in function calls; Added regression tests for cfg\_if macro formatting; Added regression tests for enum formatting edge cases; Added regression tests for format string handling; Added regression tests for import formatting (issue \#5852); Added regression tests for import granularity and formatting edge cases; Added regression tests for issue \#2482 regarding module reordering; Added regression tests for issue \#3779; Added regression tests for macro body formatting with comments; Added regression tests for macro formatting configurations; Added regression tests for macro rewriting with \asm!\ and \println!\; Added regression tests for module resolution fallback logic; Added regression tests for non-idempotent block doc comment formatting; Added regression tests for string formatting and whitespace handling; Added regression tests for struct field alignment and trailing comma formatting; Added regression tests for style edition formatting differences; Added regression tests for trailing comma handling in multi-line comments; Added run-time CPU feature detection tests for multiple architectures; Added smoke tests for the config\_proc\_macro; Added snapshot tests for formatting error warnings; Added style-edition-specific formatting tests for issue \#4689; Added test case for enum discriminant alignment threshold of 40; Added test cases for Block and Visual indent styles; Added test cases for Style Edition 2024 overflow delimiter expression handling; Added test cases for format\_macro\_bodies and format\_macro\_matchers configurations; Added test cases for function and item brace style configurations; Added test cases for import granularity and various formatting scenarios; Added test cases for imports\_layout configuration options; Added test cases for itemized markdown lists in comments; Added test cases for module reordering with case-insensitive path handling; Added test cases for multiline generic bounds formatting; Added test cases for overflow\_delimited\_expr behavior in Rust 2015 and 2024 editions; Added test cases for rustfmt::skip behavior; Added test cases for struct field alignment threshold; Added test cases for struct field alignment threshold configuration; Added test cases for trailing comment formatting with hard and soft tabs; Added test coverage for configuration snippets, module resolution, and parser error handling; Added test coverage for for-loop pattern formatting with 'in' connectors; Added test coverage for inner module path resolution; Added test coverage for issue \#4656; Added test coverage for itemized markdown lists in comments; Added test coverage for long pattern matching in lint checks; Added test coverage for module resolution with rustfmt::skip; Added test coverage for packed\_simd From/Into implementations; Added test coverage for write modes and emit formats; Added test fixtures for nested module structures; Added test for macro comment formatting; Added test for macro rewriting of const items; Added test for mixed imports layout with crate granularity; Added test for module resolution with nested modules; Added test for nested out-of-line module resolution; Added test for nested parentheses removal in function calls; Added test for qualified path formatting in macros; Added test for qualified path retention in struct literals; Added test for single-line where clause formatting; Added test for trailing semicolon retention in issue 5797; Added test for variadic function parameter attribute preservation; Added tests for NonZero type import sorting across style editions; Added tests for arrow handling in comments with style\_edition 2024; Added tests for attribute inlining and import reordering; Added tests for attribute preservation in trait functions and variadic parameters; Added tests for binop\_separator = Back; Added tests for blank\_lines\_upper\_bound configuration; Added tests for block comment formatting across style editions; Added tests for block trailing comma call formatting; Added tests for cfg\_attr module path formatting; Added tests for check\_diff functionality; Added tests for comment formatting in lists; Added tests for comment wrapping behavior; Added tests for comment wrapping in deeply nested and itemized blocks; Added tests for comment wrapping in lists; Added tests for complex function type formatting across style editions; Added tests for const generic default formatting; Added tests for derive attribute formatting with comments; Added tests for derive attribute merging and skip behavior; Added tests for doc comment code block formatting behavior; Added tests for doc comment code block small heuristics configuration; Added tests for doc comment code block width configuration; Added tests for file-lines configuration with CRLF and LF line endings; Added tests for file-lines range formatting; Added tests for formatting consistency of \assert!\ and \assert\ macros across style editions; Added tests for formatting function parameters with complex types; Added tests for generated file formatting and marker search limit; Added tests for impl generic indentation with style\_edition 2024; Added tests for import grouping and granularity configurations; Added tests for issue \#3665 regarding attribute skipping; Added tests for issue \#5801 regarding attribute and comment wrapping; Added tests for macro matcher formatting; Added tests for macro skip behavior in nested contexts; Added tests for markdown blockquote comment formatting; Added tests for markdown header handling in doc comments; Added tests for match arm attribute indentation across style editions; Added tests for module reordering across style editions; Added tests for module resolution error scenarios; Added tests for multi-file cfg\_select macro handling; Added tests for nested module and path attribute handling; Added tests for normalize\_doc\_attributes config; Added tests for out-of-line module resolution with conditional compilation; Added tests for path clarity in nested modules; Added tests for raw identifier import sorting across version gates; Added tests for rustfmt::skip attribute handling in modules; Added tests for spaces\_around\_ranges config in match patterns; Added tests for spacing around range expressions; Added tests for string formatting in macro definitions; Added tests for struct field alignment in block and visual styles; Added tests for struct field alignment in match patterns and enum variants; Added tests for struct pattern formatting with trailing commas; Added tests for style\_edition configuration derivation; Added tests for the reorder\_modules configuration option; Added tests for the use\_field\_init\_shorthand config option; Added tests for trace! macro formatting consistency; Added tests for trailing comma preservation in single-line macros; Added tests for trailing comment formatting with hard tabs; Added tests for trailing semicolon enforcement in loop bodies; Added tests for trailing semicolon formatting in match arms across style editions; Added tests for use\_small\_heuristics configuration options; Added tests for where-clause formatting in style edition 2024; Added unit tests for cargo-fmt argument parsing and target discovery.

Dependencies

Rustfmt 1.11.0 dependency update and lockfile generation

This change updates the Rustfmt project to version 1.11.0 and introduces Cargo.lock files for the main crate, the \check\_diff\ utility, the \config\_proc\_macro\ crate, and the CI integration tool. It upgrades key dependencies including \clap\ to 4.5, \itertools\ to 0.15, \toml\ to 1.1, and \annotate-snippets\ to 0.12, while also updating the \rustfmt-config\_proc\_macro\ to version 0.3.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 65 → 63 (-1.7)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 59 → 51 (-8.0)
  • Architecture 93 → 93 (+0.0)
  • Maturity 65 → 65 (+0.0)
  • Readiness 67 → 73 (+6.1)
  • Security 76 → 100 (+23.9)
  • Performance 85 → 85 (+0.0)

Resolved (17)

  • Duplicated block (13 lines × 2) (src/items.rs)
  • Duplicated block (16 lines × 2) (src/modules.rs)
  • Duplicated block (6 lines × 2) (src/parse/macros/cfg_if.rs)
  • Duplicated block (8–9 lines × 2) (src/matches.rs)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Hotspot: src/bin/main.rs (src/bin/main.rs)
  • Hotspot: src/chains.rs (src/chains.rs)
  • Hotspot: src/macros.rs (src/macros.rs)
  • No ADRs found
  • No SBOM
  • No artifact signing
  • No build provenance
  • No checksums published for release artifacts
  • Off-boarding risk: anonymized user #1
  • Release-publishing job runs with an unscoped token (.github/workflows/upload-assets.yml)

New (24)

  • Duplicated block (13 lines × 2) (src/items.rs)
  • Duplicated block (14 lines × 2) (check_diff/src/lib.rs)
  • Duplicated block (16 lines × 2) (src/modules.rs)
  • Duplicated block (6 lines × 2) (src/parse/macros/cfg_if.rs)
  • Duplicated block (8–9 lines × 2) (src/matches.rs)
  • Edited copies of one member (3 members, 11+ corresponding lines) (src/parse/macros/cfg_if.rs)
  • Edited copies of one member (3 members, 18+ corresponding lines) (check_diff/src/lib.rs)
  • Edited copy of a member (10 corresponding lines) (src/closures.rs)
  • Edited copy of a member (10 corresponding lines) (src/source_map.rs)
  • Edited copy of a member (11 corresponding lines) (src/macros.rs)
  • Edited copy of a member (13 corresponding lines) (src/modules.rs)
  • Edited copy of a member (18 corresponding lines) (src/modules.rs)
  • Edited copy of a member (20 corresponding lines) (src/header.rs)
  • Edited copy of a member (25 corresponding lines) (src/modules.rs)
  • Edited copy of a member (28 corresponding lines) (src/modules/visitor.rs)
  • Edited copy of a member (32 corresponding lines) (src/sort.rs)
  • Edited copy of a member (36 corresponding lines) (check_diff/src/lib.rs)
  • Edited copy of a member (59 corresponding lines) (src/parse/macros/cfg_if.rs)
  • Edited copy of a member (9 corresponding lines) (check_diff/src/lib.rs)
  • Edited copy of a member (9 corresponding lines) (src/bin/main.rs)
  • …and 4 more

Changes since last survey

  • 70 commits — 59 feature/other, 11 fixes

By area

  • (repo) — 19 commits
  • .github/workflows — 19 commits
  • (root) — 10 commits
  • tests/source — 6 commits
  • tests/rustfmt — 4 commits
  • tests/target — 4 commits
  • src/config — 2 commits
  • check_diff/src — 1 commit
  • src/bin — 1 commit
  • src/comment.rs — 1 commit
  • src/items.rs — 1 commit
  • src/macros.rs — 1 commit
  • src/test — 1 commit

Notable commits

  • fix: Add pre-fix tests for rust-lang/rustfmt#6612
  • fix: Add regression tests for trailing multiline block comments
  • fix: Add style edition 2021 regression test
  • fix: Fix trailing multiline block comments while preserving older style editions
  • fix: Merge pull request #7222 from jieyouxu/jieyouxu/revert-macro-fmt
  • fix: Merge pull request #7228 from jieyouxu/jieyouxu/fix-ci
  • fix: Revert "Fixes adjustment of max_width within macros"
  • fix: Revert "Use saturating arithmetics for adjust_max_width"
  • fix: fix(cfg_select): respect control_brace_style config
  • fix: fix: remove uncommented empty where clauses after return types
  • fix: tests: fix up some line endings
  • change: Add additional test case which errored with trailing whitespace
  • change: Allow reading args from @path
  • change: Derive Debug for comment::CommentStyle
  • change: Don't split link destinations when wrap_comments is enabled
  • change: Error on --print-config minimal with no output path
  • change: Integration test: assert on exit codes
  • change: Merge pull request #5392 from ytmimi/issue_5391
  • change: Merge pull request #6167 from mu001999-contrib/master
  • change: Merge pull request #7197 from AlexeyL54/comment-7177-dont-split-link-destinations
  • …and 50 more

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

rust-lang/rustfmt was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 702df60b87e5047276b0d4c36c989e8095555e00 — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-e1a3b69fc8ee.