cargo check: Usage, Options & Common CI Errors
Catch compile errors fast - without codegen.
cargo check compiles your code far enough to report errors and warnings but skips code generation and linking, so it is much faster than cargo build. It is the ideal first gate in a pipeline.
What it does
Runs the front end of the compiler (parsing, type checking, borrow checking) and stops before emitting machine code. It produces no runnable binary.
Common usage
cargo check # check the current package
cargo check --workspace # check all members
cargo check --all-targets # include tests, examples, benches
cargo check --locked --all-featuresCommon CI error: passes check, fails build
cargo check is green but cargo build --release fails. That happens because check skips codegen and linking, so linker errors, const-eval that only runs in codegen, and some monomorphization errors only surface in a real build. Run cargo build (or cargo test) on the same matrix entry you ship, not just check.
Options
| Flag | Effect |
|---|---|
| --workspace | Check all workspace members |
| --all-targets | Check tests, examples, benches |
| --all-features | Enable every feature |
| --message-format json | Machine-readable diagnostics |