1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Loom
# Loom exhaustively explores concurrent interleavings to catch bugs that
# are only probabilistic under stress tests. Tests live in `tests/loom.rs`
# and are gated behind `#![cfg(loom)]`.
#
# Loom only sees code that uses its substituted primitives
# (`loom::sync::*`, `loom::thread::*`). The vendored `RawRwLock` in
# `src/lock.rs` uses `parking_lot_core` directly, so loom does not model
# the lock itself — see the file-level comment in `tests/loom.rs` for the
# scope of what these tests cover.
on:
push:
branches:
paths:
- "src/**"
- "tests/loom.rs"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/loom.yml"
pull_request:
branches:
paths:
- "src/**"
- "tests/loom.rs"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/loom.yml"
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
# `--cfg loom` activates the gated test module; release optimisation
# cuts the model-checker's run time roughly in half.
RUSTFLAGS: "--cfg loom -C debug-assertions"
# Optional knobs for tuning the model checker. See:
# https://github.com/tokio-rs/loom#environment-variables
# LOOM_MAX_PREEMPTIONS bounds how many forced thread switches loom may
# insert per iteration — 3 is loom's recommended default and catches
# almost all real-world bugs at a fraction of the cost of full
# exploration.
LOOM_MAX_PREEMPTIONS: "3"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
loom:
name: cargo test --cfg loom
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master @ 2026-03-27
with:
toolchain: stable
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
key: loom
- name: cargo test --release --test loom
run: cargo test --release --test loom