Reference configs

rust-lang/rust: tidy's file checks, as YAML

rust-lang/rust checks itself with tidy, about 7,700 lines of Rust; adding a check means writing a module. tidy's file-level checks, from line length to the Cargo edition, fit in YAML rules, and the ones that need Rust's parser stay in tidy. This config was written to test alint; the Rust project doesn't use alint.

What alint found

.alint.yml
extends:
  - alint://bundled/rust@v1
  - alint://bundled/ci/github-actions@v1

⚠︎ warning rust-sources-final-newline

The rule flags 149 Rust files with no final newline. Of those, 141 are test inputs in rust-analyzer and rustfmt, which tidy skips, and the other 8 are tests marked // ignore-tidy-trailing-newlines, so a config for this repository would leave both out.

The bundled GitHub Actions rules (alint 0.16.1, on the workflows as of 7 May 2026) flag 12 action references in its 4 workflows that use a tag, such as actions/checkout@v5, instead of a commit.

The config

The config has rules for tidy's style check (line length, file length, trailing whitespace, LF endings, TODO markers), the Rust edition in each crate's Cargo.toml and the allowed package sources in Cargo.lock, a known-bug line in every crash test and no #[test] inside the standard library crates. It runs rustfmt, typos, Ruff and ShellCheck from command and command_idempotent rules. The style rules don't yet leave out what tidy leaves out, such as the rust-analyzer and Clippy sources and lines marked ignore-tidy-*.

.alint.yml
- id: rust-tidy-cargo-edition
  # fixed here: skips virtual workspaces, which have no edition, and the directories tidy skips
  kind: toml_path_matches
  paths:
    include:
      - "compiler/**/Cargo.toml"
      - "library/**/Cargo.toml"
      - "src/**/Cargo.toml"
    exclude:
      - "library/Cargo.toml"
      - "compiler/rustc_codegen_{cranelift,gcc}/**"
      - "library/{backtrace,compiler-builtins,portable-simd,stdarch}/**"
      - "src/{gcc,llvm-project}/**"
      - "src/doc/{book,edition-guide,embedded-book,nomicon,reference,rust-by-example,rustc-dev-guide}/**"
      - "src/tools/{cargo,clippy,enzyme,libcxx-version,miri,rust-analyzer,rustc-perf,rustfmt}/**"
  path: "$.package.edition"
  matches: '^(2021|2024)$'
  level: error

tidy's edition check: each crate's Cargo.toml under compiler/, library/ and src/ sets edition 2021 or 2024. Virtual workspaces can't set one, and the directories tidy skips, such as the LLVM and GCC trees and the tools developed in their own repositories, are left out.

.alint.yml
- id: rust-tidy-crashes-known-bug
  # fixed here: the directive can be on any line, so `^` needs `(?m)`
  kind: file_content_matches
  paths:
    include: ["tests/crashes/**/*.rs"]
    exclude: ["tests/crashes/auxiliary/**"]
  pattern: '(?m)^//@ known-bug:'
  level: error

Every crash test names the issue it reproduces in a known-bug directive.

.alint.yml
- id: rust-tidy-no-test-in-stdlib
  # fixed here: `(?m)`, so `^` matches every line, and the files tidy checks
  kind: file_content_forbidden
  paths:
    include: ["library/**/*.rs"]
    exclude:
      - "library/{backtrace,compiler-builtins,portable-simd,stdarch}/**"
      - "library/{std,std_detect,test}/**"
      - "library/*tests/**"
      - "library/alloc/src/collections/btree/{borrow,map,node,set}/tests.rs"
      - "library/alloc/src/collections/{linked_list,vec_deque}/tests.rs"
      - "library/alloc/src/{raw_vec,wtf8}/tests.rs"
  pattern: '(?m)^\s*#\[(test|bench)\]'
  level: error

The standard library's tests live in separate crates, such as coretests and alloctests, not inline in its source. Like tidy, the rule exempts std and eight of alloc's test files.

What stays outside alint

These stay in tidy:

  • features and the unstable book, error codes and their docs, and where platform-specific code may live;
  • target policies, compiletest headers and the dependency license allowlist, which reads Cargo's resolved dependency graph;
  • checks with no rule kind yet, such as matching theme blocks across two CSS files and balanced template tags.