1CARGO-CHECK(1) CARGO-CHECK(1)
2
3
4
6 cargo-check - Check the current package
7
9 cargo check [OPTIONS]
10
12 Check a local package and all of its dependencies for errors. This will
13 essentially compile the packages without performing the final step of
14 code generation, which is faster than running cargo build. The compiler
15 will save metadata files to disk so that future runs will reuse them if
16 the source has not been modified.
17
19 Package Selection
20 By default, when no package selection options are given, the packages
21 selected depend on the current working directory. In the root of a
22 virtual workspace, all workspace members are selected (--all is
23 implied). Otherwise, only the package in the current directory will be
24 selected. The default packages may be overridden with the
25 workspace.default-members key in the root Cargo.toml manifest.
26
27 -p SPEC..., --package SPEC...
28 Check only the specified packages. See cargo-pkgid(1) for the SPEC
29 format. This flag may be specified multiple times.
30
31 --all
32 Check all members in the workspace.
33
34 --exclude SPEC...
35 Exclude the specified packages. Must be used in conjunction with
36 the --all flag. This flag may be specified multiple times.
37
38 Target Selection
39 When no target selection options are given, cargo check will check all
40 binary and library targets of the selected packages. Binaries are
41 skipped if they have required-features that are missing.
42
43 Passing target selection flags will check only the specified targets.
44
45 --lib
46 Check the package’s library.
47
48 --bin NAME...
49 Check the specified binary. This flag may be specified multiple
50 times.
51
52 --bins
53 Check all binary targets.
54
55 --example NAME...
56 Check the specified example. This flag may be specified multiple
57 times.
58
59 --examples
60 Check all example targets.
61
62 --test NAME...
63 Check the specified integration test. This flag may be specified
64 multiple times.
65
66 --tests
67 Check all targets in test mode that have the test = true manifest
68 flag set. By default this includes the library and binaries built
69 as unittests, and integration tests. Be aware that this will also
70 build any required dependencies, so the lib target may be built
71 twice (once as a unittest, and once as a dependency for binaries,
72 integration tests, etc.). Targets may be enabled or disabled by
73 setting the test flag in the manifest settings for the target.
74
75 --bench NAME...
76 Check the specified benchmark. This flag may be specified multiple
77 times.
78
79 --benches
80 Check all targets in benchmark mode that have the bench = true
81 manifest flag set. By default this includes the library and
82 binaries built as benchmarks, and bench targets. Be aware that this
83 will also build any required dependencies, so the lib target may be
84 built twice (once as a benchmark, and once as a dependency for
85 binaries, benchmarks, etc.). Targets may be enabled or disabled by
86 setting the bench flag in the manifest settings for the target.
87
88 --all-targets
89 Check all targets. This is equivalent to specifying --lib --bins
90 --tests --benches --examples.
91
92 Feature Selection
93 When no feature options are given, the default feature is activated for
94 every selected package.
95
96 --features FEATURES
97 Space or comma separated list of features to activate. These
98 features only apply to the current directory’s package. Features of
99 direct dependencies may be enabled with <dep-name>/<feature-name>
100 syntax.
101
102 --all-features
103 Activate all available features of all selected packages.
104
105 --no-default-features
106 Do not activate the default feature of the current directory’s
107 package.
108
109 Compilation Options
110 --target TRIPLE
111 Check for the given architecture. The default is the host
112 architecture. The general format of the triple is
113 <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
114 a list of supported targets.
115
116 This may also be specified with the build.target config value
117 <https://doc.rust-lang.org/cargo/reference/config.html>.
118
119 --release
120 Check optimized artifacts with the release profile. See the
121 PROFILES section for details on how this affects profile selection.
122
123 --profile NAME
124 Changes check behavior. Currently only test is supported, which
125 will check with the #[cfg(test)] attribute enabled. This is useful
126 to have it check unit tests which are usually excluded via the cfg
127 attribute. This does not change the actual profile used.
128
129 Output Options
130 --target-dir DIRECTORY
131 Directory for all generated artifacts and intermediate files. May
132 also be specified with the CARGO_TARGET_DIR environment variable,
133 or the build.target-dir config value
134 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
135 to target in the root of the workspace.
136
137 Display Options
138 -v, --verbose
139 Use verbose output. May be specified twice for "very verbose"
140 output which includes extra output such as dependency warnings and
141 build script output. May also be specified with the term.verbose
142 config value
143 <https://doc.rust-lang.org/cargo/reference/config.html>.
144
145 -q, --quiet
146 No output printed to stdout.
147
148 --color WHEN
149 Control when colored output is used. Valid values:
150
151 · auto (default): Automatically detect if color support is
152 available on the terminal.
153
154 · always: Always display colors.
155
156 · never: Never display colors.
157
158 May also be specified with the term.color config value
159 <https://doc.rust-lang.org/cargo/reference/config.html>.
160
161 --message-format FMT
162 The output format for diagnostic messages. Valid values:
163
164 · human (default): Display in a human-readable text format.
165
166 · json: Emit JSON messages to stdout.
167
168 · short: Emit shorter, human-readable text messages.
169
170 Manifest Options
171 --manifest-path PATH
172 Path to the Cargo.toml file. By default, Cargo searches in the
173 current directory or any parent directory for the Cargo.toml file.
174
175 --frozen, --locked
176 Either of these flags requires that the Cargo.lock file is
177 up-to-date. If the lock file is missing, or it needs to be updated,
178 Cargo will exit with an error. The --frozen flag also prevents
179 Cargo from attempting to access the network to determine if it is
180 out-of-date.
181
182 These may be used in environments where you want to assert that the
183 Cargo.lock file is up-to-date (such as a CI build) or want to avoid
184 network access.
185
186 Common Options
187 -h, --help
188 Prints help information.
189
190 -Z FLAG...
191 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
192 details.
193
194 Miscellaneous Options
195 -j N, --jobs N
196 Number of parallel jobs to run. May also be specified with the
197 build.jobs config value
198 <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
199 to the number of CPUs.
200
202 Profiles may be used to configure compiler options such as optimization
203 levels and debug settings. See the reference
204 <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
205 for more details.
206
207 Profile selection depends on the target and crate being built. By
208 default the dev or test profiles are used. If the --release flag is
209 given, then the release or bench profiles are used.
210
211 ┌────────────────────┬─────────────────┬───────────────────┐
212 │ │ │ │
213 │Target │ Default Profile │ --release Profile │
214 ├────────────────────┼─────────────────┼───────────────────┤
215 │ │ │ │
216 │lib, bin, example │ dev │ release │
217 ├────────────────────┼─────────────────┼───────────────────┤
218 │ │ │ │
219 │test, bench, or any │ test │ bench │
220 │target │ │ │
221 │in "test" or │ │ │
222 │"bench" mode │ │ │
223 └────────────────────┴─────────────────┴───────────────────┘
224
225 Dependencies use the dev/release profiles.
226
228 See the reference
229 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
230 for details on environment variables that Cargo reads.
231
233 0
234 Cargo succeeded.
235
236 101
237 Cargo failed to complete.
238
240 1. Check the local package for errors:
241
242 cargo check
243
244 2. Check all targets, including unit tests:
245
246 cargo check --all-targets --profile=test
247
249 cargo(1), cargo-build(1)
250
251
252
253 2018-12-20 CARGO-CHECK(1)