cargo-fa-0.11.1 is not a library.
Overview
cargo-fa is a static analysis tool for framealloc that detects memory intent violations at build time. It catches patterns that compile but violate frame allocation principles — issues that would otherwise only surface as performance problems or subtle bugs at runtime.
What It Catches
| Category | Examples |
|---|---|
| Lifetime Issues | Frame allocations escaping scope, hot loop allocations |
| Async Safety | Frame data crossing await points, closure captures |
| Threading | Cross-thread frame access, missing thread-local init |
| Architecture | Tag mismatches, unknown tags, module boundary violations |
| Budgets | Unbounded allocation loops |
Installation
Or from source:
Usage
Basic Checks
# Check specific categories
# Run all checks (optimized order)
Filtering
# Treat specific diagnostic as error
# Suppress specific diagnostic
# Exclude paths (glob pattern)
# Stop on first error
# Minimum severity threshold
Output Formats
# Human-readable (default)
# JSON for programmatic consumption
# SARIF for GitHub Actions
# JUnit XML for test reporters
# Checkstyle XML for Jenkins
# Compact one-line-per-issue
Subcommands
# Explain a diagnostic code in detail
# Analyze a single file
# List all diagnostic codes
# Filter by category
# Generate configuration file
Diagnostics
Diagnostic Codes
| Range | Category | Description |
|---|---|---|
| FA2xx | Threading | Cross-thread frame access, thread-local issues |
| FA3xx | Budgets | Unbounded allocations, missing budget guards |
| FA6xx | Lifetime | Frame escape, hot loops, missing boundaries |
| FA7xx | Async | Await crossing, closure capture, async functions |
| FA8xx | Architecture | Tag mismatch, unknown tags, module violations |
| FA9xx | Rapier | Physics engine integration issues (Rapier 0.31) |
Example Output
error[FA701]: frame allocation in async function
--> src/network/client.rs:45:12
|
45 | let buffer = alloc.frame_box(vec![0u8; 1024]);
| ^^^^^^ frame allocation here
|
= note: async functions can suspend across frame boundaries
= help: use `alloc.heap_box()` or `alloc.pool_box()` instead
warning[FA602]: allocation in hot loop
--> src/physics/collision.rs:128:16
|
128| let contact = alloc.pool_alloc::<Contact>();
| ^^^^^^ allocation inside loop
|
= note: loop may execute many times per frame
= help: consider pre-allocating with `alloc.frame_vec()`
Getting Detailed Explanations
)
&) {
)
&) {
CI Integration
GitHub Actions (SARIF)
- name: Run cargo-fa
run: cargo fa --all --format sarif > results.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
Jenkins (Checkstyle)
Generic CI
# Exit with error on any issues
# Exit with error only on specific codes
Configuration
Create a .fa.toml in your project root:
Example configuration:
[]
= true
= ["target/**", "tests/**"]
[]
= "warn"
[]
= "deny"
[]
= ["physics", "rendering", "audio", "network"]
[]
= "physics"
= "rendering"
Related
- framealloc — The memory allocation library
- TECHNICAL.md — Architecture documentation
License
Licensed under either of:
at your option.