1CARGO-CHECK(1)                                                  CARGO-CHECK(1)
2
3
4

NAME

6       cargo-check - Check the current package
7

SYNOPSIS

9       cargo check [OPTIONS]
10

DESCRIPTION

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

OPTIONS

19   Package Selection
20       By default, when no package selection options are given, the packages
21       selected depend on the selected manifest file (based on the current
22       working directory if --manifest-path is not given). If the manifest is
23       the root of a workspace then the workspaces default members are
24       selected, otherwise only the package defined by the manifest will be
25       selected.
26
27       The default members of a workspace can be set explicitly with the
28       workspace.default-members key in the root manifest. If this is not set,
29       a virtual workspace will include all workspace members (equivalent to
30       passing --workspace), and a non-virtual workspace will include only the
31       root crate itself.
32
33       -p SPEC..., --package SPEC...
34           Check only the specified packages. See cargo-pkgid(1) for the SPEC
35           format. This flag may be specified multiple times.
36
37       --workspace
38           Check all members in the workspace.
39
40       --all
41           Deprecated alias for --workspace.
42
43       --exclude SPEC...
44           Exclude the specified packages. Must be used in conjunction with
45           the --workspace flag. This flag may be specified multiple times.
46
47   Target Selection
48       When no target selection options are given, cargo check will check all
49       binary and library targets of the selected packages. Binaries are
50       skipped if they have required-features that are missing.
51
52       Passing target selection flags will check only the specified targets.
53
54       --lib
55           Check the package’s library.
56
57       --bin NAME...
58           Check the specified binary. This flag may be specified multiple
59           times.
60
61       --bins
62           Check all binary targets.
63
64       --example NAME...
65           Check the specified example. This flag may be specified multiple
66           times.
67
68       --examples
69           Check all example targets.
70
71       --test NAME...
72           Check the specified integration test. This flag may be specified
73           multiple times.
74
75       --tests
76           Check all targets in test mode that have the test = true manifest
77           flag set. By default this includes the library and binaries built
78           as unittests, and integration tests. Be aware that this will also
79           build any required dependencies, so the lib target may be built
80           twice (once as a unittest, and once as a dependency for binaries,
81           integration tests, etc.). Targets may be enabled or disabled by
82           setting the test flag in the manifest settings for the target.
83
84       --bench NAME...
85           Check the specified benchmark. This flag may be specified multiple
86           times.
87
88       --benches
89           Check all targets in benchmark mode that have the bench = true
90           manifest flag set. By default this includes the library and
91           binaries built as benchmarks, and bench targets. Be aware that this
92           will also build any required dependencies, so the lib target may be
93           built twice (once as a benchmark, and once as a dependency for
94           binaries, benchmarks, etc.). Targets may be enabled or disabled by
95           setting the bench flag in the manifest settings for the target.
96
97       --all-targets
98           Check all targets. This is equivalent to specifying --lib --bins
99           --tests --benches --examples.
100
101   Feature Selection
102       The feature flags allow you to control the enabled features for the
103       "current" package. The "current" package is the package in the current
104       directory, or the one specified in --manifest-path. If running in the
105       root of a virtual workspace, then the default features are selected for
106       all workspace members, or all features if --all-features is specified.
107
108       When no feature options are given, the default feature is activated for
109       every selected package.
110
111       --features FEATURES
112           Space or comma separated list of features to activate. These
113           features only apply to the current directory’s package. Features of
114           direct dependencies may be enabled with <dep-name>/<feature-name>
115           syntax. This flag may be specified multiple times, which enables
116           all specified features.
117
118       --all-features
119           Activate all available features of all selected packages.
120
121       --no-default-features
122           Do not activate the default feature of the current directory’s
123           package.
124
125   Compilation Options
126       --target TRIPLE
127           Check for the given architecture. The default is the host
128           architecture. The general format of the triple is
129           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
130           a list of supported targets.
131
132           This may also be specified with the build.target config value
133           <https://doc.rust-lang.org/cargo/reference/config.html>.
134
135           Note that specifying this flag makes Cargo run in a different mode
136           where the target artifacts are placed in a separate directory. See
137           the build cache
138           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
139           documentation for more details.
140
141       --release
142           Check optimized artifacts with the release profile. See the
143           PROFILES section for details on how this affects profile selection.
144
145       --profile NAME
146           Changes check behavior. Currently only test is supported, which
147           will check with the #[cfg(test)] attribute enabled. This is useful
148           to have it check unit tests which are usually excluded via the cfg
149           attribute. This does not change the actual profile used.
150
151   Output Options
152       --target-dir DIRECTORY
153           Directory for all generated artifacts and intermediate files. May
154           also be specified with the CARGO_TARGET_DIR environment variable,
155           or the build.target-dir config value
156           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
157           to target in the root of the workspace.
158
159   Display Options
160       -v, --verbose
161           Use verbose output. May be specified twice for "very verbose"
162           output which includes extra output such as dependency warnings and
163           build script output. May also be specified with the term.verbose
164           config value
165           <https://doc.rust-lang.org/cargo/reference/config.html>.
166
167       -q, --quiet
168           No output printed to stdout.
169
170       --color WHEN
171           Control when colored output is used. Valid values:
172
173           ·   auto (default): Automatically detect if color support is
174               available on the terminal.
175
176           ·   always: Always display colors.
177
178           ·   never: Never display colors.
179
180           May also be specified with the term.color config value
181           <https://doc.rust-lang.org/cargo/reference/config.html>.
182
183       --message-format FMT
184           The output format for diagnostic messages. Can be specified
185           multiple times and consists of comma-separated values. Valid
186           values:
187
188           ·   human (default): Display in a human-readable text format.
189
190           ·   short: Emit shorter, human-readable text messages.
191
192           ·   json: Emit JSON messages to stdout. See the reference
193               <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
194               for more details.
195
196           ·   json-diagnostic-short: Ensure the rendered field of JSON
197               messages contains the "short" rendering from rustc.
198
199           ·   json-diagnostic-rendered-ansi: Ensure the rendered field of
200               JSON messages contains embedded ANSI color codes for respecting
201               rustc’s default color scheme.
202
203           ·   json-render-diagnostics: Instruct Cargo to not include rustc
204               diagnostics in in JSON messages printed, but instead Cargo
205               itself should render the JSON diagnostics coming from rustc.
206               Cargo’s own JSON diagnostics and others coming from rustc are
207               still emitted.
208
209   Manifest Options
210       --manifest-path PATH
211           Path to the Cargo.toml file. By default, Cargo searches for the
212           Cargo.toml file in the current directory or any parent directory.
213
214       --frozen, --locked
215           Either of these flags requires that the Cargo.lock file is
216           up-to-date. If the lock file is missing, or it needs to be updated,
217           Cargo will exit with an error. The --frozen flag also prevents
218           Cargo from attempting to access the network to determine if it is
219           out-of-date.
220
221           These may be used in environments where you want to assert that the
222           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
223           network access.
224
225       --offline
226           Prevents Cargo from accessing the network for any reason. Without
227           this flag, Cargo will stop with an error if it needs to access the
228           network and the network is not available. With this flag, Cargo
229           will attempt to proceed without the network if possible.
230
231           Beware that this may result in different dependency resolution than
232           online mode. Cargo will restrict itself to crates that are
233           downloaded locally, even if there might be a newer version as
234           indicated in the local copy of the index. See the cargo-fetch(1)
235           command to download dependencies before going offline.
236
237           May also be specified with the net.offline config value
238           <https://doc.rust-lang.org/cargo/reference/config.html>.
239
240   Common Options
241       -h, --help
242           Prints help information.
243
244       -Z FLAG...
245           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
246           details.
247
248   Miscellaneous Options
249       -j N, --jobs N
250           Number of parallel jobs to run. May also be specified with the
251           build.jobs config value
252           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
253           to the number of CPUs.
254

PROFILES

256       Profiles may be used to configure compiler options such as optimization
257       levels and debug settings. See the reference
258       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
259       details.
260
261       Profile selection depends on the target and crate being built. By
262       default the dev or test profiles are used. If the --release flag is
263       given, then the release or bench profiles are used.
264
265       ┌────────────────────┬─────────────────┬───────────────────┐
266       │                    │                 │                   │
267       │Target              │ Default Profile │ --release Profile │
268       ├────────────────────┼─────────────────┼───────────────────┤
269       │                    │                 │                   │
270       │lib, bin, example   │ dev             release           
271       ├────────────────────┼─────────────────┼───────────────────┤
272       │                    │                 │                   │
273       │test, bench, or any │ test            bench             
274       │target              │                 │                   │
275       │in "test" or        │                 │                   │
276       │"bench" mode        │                 │                   │
277       └────────────────────┴─────────────────┴───────────────────┘
278
279       Dependencies use the dev/release profiles.
280

ENVIRONMENT

282       See the reference
283       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
284       for details on environment variables that Cargo reads.
285

EXIT STATUS

287       0
288           Cargo succeeded.
289
290       101
291           Cargo failed to complete.
292

EXAMPLES

294        1. Check the local package for errors:
295
296               cargo check
297
298        2. Check all targets, including unit tests:
299
300               cargo check --all-targets --profile=test
301

SEE ALSO

303       cargo(1), cargo-build(1)
304
305
306
307                                  2019-09-05                    CARGO-CHECK(1)
Impressum