cargo-check
Check Rust code for errors quickly
TLDR
Check the current package
Check all tests
Check the integration tests in tests/integration_test1.rs
Check the current package with the features feature1 and feature2
Check the current package with default features disabled
SYNOPSIS
cargo check [OPTIONS] [--] [<PATH> ...]
PARAMETERS
--all
Check all packages in workspace (alias for --workspace)
--all-features
Activate all available features
--all-targets
Check all targets (lib, bins, tests, etc.; default)
--bins
Check all binaries
--document, --doc
Check documentation
--examples
Check all examples
--features FEATURES
Space or comma-separated list of features to activate
--jobs N, -j N
Number of parallel jobs (default: CPU cores)
--lib
Check only the library target
--manifest-path PATH
Path to Cargo.toml
--no-default-features
Do not activate default features
-p SPEC, --package SPEC
Package to check (e.g., name, path)
--release
Check in release mode (optimized)
--target TRIPLE
Target triple (e.g., x86_64-unknown-linux-gnu)
--target-dir DIR
Target directory path
--tests
Check all tests
-v, --verbose
Use verbose output
-q, --quiet
No output printed
--workspace
Check all workspace members
--offline
Operate without network access
--frozen
Require Cargo.lock and no dependency updates
--color WHEN
Control colored output (auto, always, never)
DESCRIPTION
cargo check is a core subcommand of Cargo, Rust's build tool and package manager. It compiles Rust source code solely to verify syntax, type safety, borrow rules, and other compile-time checks, halting before code generation, optimization, or linking. This delivers rapid feedback—often 10x faster than cargo build—ideal for iterative development, editor integrations like rust-analyzer, and CI pre-checks.
It processes Cargo.toml configurations, resolves dependencies via Cargo.lock, and supports crates, workspaces, targets (e.g., cross-compilation), features, and profiles (dev/release). Errors display with source spans, similar to full builds, aiding quick fixes. While it misses linker errors (e.g., missing C libraries) or runtime issues, it's indispensable for catching 90%+ of bugs early.
Usage spans single crates to monorepos, enhancing productivity without binary overhead.
CAVEATS
Skips linking, so misses linker errors (e.g., undefined symbols, C libs); no runtime or test execution; output dir not configurable like builds.
EXAMPLES
cargo check
Check current package (default).
cargo check --release --target wasm32-unknown-unknown
Release check for WebAssembly.
cargo check -p mylib --lib --tests
Check library and tests in specific package.
INTEGRATION
Pairs with rust-analyzer LSP for IDEs (VS Code, etc.); use in Makefile: check: cargo check --workspace.
HISTORY
Introduced in Cargo 0.6.0 (2015) by the Rust team at Mozilla for faster dev cycles; matured with workspaces (Cargo 0.23), edition support, and Rust 2018+ features.
SEE ALSO
cargo(1), cargo-build(1), cargo-test(1), cargo-clippy(1), rustc(1)


