Skip to content

M0004 no-sys-crates

Rule: The dependency graph has no -sys crates and no C build steps.

Code M0004 (stable, never reused)
Id no-sys-crates
Category dependencies
Source spirit_level
Fix by hand
Needs the resolved dependency graph (full cargo metadata)

Level per tier

Tier Level Reason
small deny pure-Rust crates only: no bundled C, no -sys bindings without a written reason
small-workspace deny pure-Rust crates only: no bundled C, no -sys bindings without a written reason
medium deny pure-Rust crates only: no bundled C, no -sys bindings without a written reason
big deny pure-Rust crates only: no bundled C, no -sys bindings without a written reason
ai off
embedded off
ui off
egui off
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
allow list of strings [] crates allowed anyway, each named with its reason in AGENTS.md

Why

C libraries bring memory bugs Rust cannot see and builds that need a C toolchain, system libraries and cross-compilers (static musl, Windows, embedded). The house rule is pure-Rust crates: rustls not OpenSSL, gix not git2.

The lint reads the resolved graph (normal, build and dev edges of every member) and reports crates that are a C build step (cc, bindgen, cmake, pkg-config, vcpkg, autotools) or link a native library (links in their manifest). Pure-Rust binding crates such as windows-sys declare neither and are not reported.

How to fix

Find who pulls it with cargo tree -i NAME -e normal,build, and pick a pure-Rust crate or turn off the feature that pulls it. When it must stay, list it in the parameter allow and write the reason in AGENTS.md.

Configure

[lints.no-sys-crates]
level = "deny"
allow = []
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(no-sys-crates) <reason> (waivers); the code works there too, as in [lints.M0004].