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       When no feature options are given, the default feature is activated for
103       every selected package.
104
105       --features FEATURES
106           Space or comma separated list of features to activate. These
107           features only apply to the current directory’s package. Features of
108           direct dependencies may be enabled with <dep-name>/<feature-name>
109           syntax.
110
111       --all-features
112           Activate all available features of all selected packages.
113
114       --no-default-features
115           Do not activate the default feature of the current directory’s
116           package.
117
118   Compilation Options
119       --target TRIPLE
120           Check for the given architecture. The default is the host
121           architecture. The general format of the triple is
122           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
123           a list of supported targets.
124
125           This may also be specified with the build.target config value
126           <https://doc.rust-lang.org/cargo/reference/config.html>.
127
128       --release
129           Check optimized artifacts with the release profile. See the
130           PROFILES section for details on how this affects profile selection.
131
132       --profile NAME
133           Changes check behavior. Currently only test is supported, which
134           will check with the #[cfg(test)] attribute enabled. This is useful
135           to have it check unit tests which are usually excluded via the cfg
136           attribute. This does not change the actual profile used.
137
138   Output Options
139       --target-dir DIRECTORY
140           Directory for all generated artifacts and intermediate files. May
141           also be specified with the CARGO_TARGET_DIR environment variable,
142           or the build.target-dir config value
143           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
144           to target in the root of the workspace.
145
146   Display Options
147       -v, --verbose
148           Use verbose output. May be specified twice for "very verbose"
149           output which includes extra output such as dependency warnings and
150           build script output. May also be specified with the term.verbose
151           config value
152           <https://doc.rust-lang.org/cargo/reference/config.html>.
153
154       -q, --quiet
155           No output printed to stdout.
156
157       --color WHEN
158           Control when colored output is used. Valid values:
159
160           ·   auto (default): Automatically detect if color support is
161               available on the terminal.
162
163           ·   always: Always display colors.
164
165           ·   never: Never display colors.
166
167           May also be specified with the term.color config value
168           <https://doc.rust-lang.org/cargo/reference/config.html>.
169
170       --message-format FMT
171           The output format for diagnostic messages. Can be specified
172           multiple times and consists of comma-separated values. Valid
173           values:
174
175           ·   human (default): Display in a human-readable text format.
176
177           ·   short: Emit shorter, human-readable text messages.
178
179           ·   json: Emit JSON messages to stdout.
180
181           ·   json-diagnostic-short: Ensure the rendered field of JSON
182               messages contains the "short" rendering from rustc.
183
184           ·   json-diagnostic-rendered-ansi: Ensure the rendered field of
185               JSON messages contains embedded ANSI color codes for respecting
186               rustc’s default color scheme.
187
188           ·   json-render-diagnostics: Instruct Cargo to not include rustc
189               diagnostics in in JSON messages printed, but instead Cargo
190               itself should render the JSON diagnostics coming from rustc.
191               Cargo’s own JSON diagnostics and others coming from rustc are
192               still emitted.
193
194   Manifest Options
195       --manifest-path PATH
196           Path to the Cargo.toml file. By default, Cargo searches in the
197           current directory or any parent directory for the Cargo.toml file.
198
199       --frozen, --locked
200           Either of these flags requires that the Cargo.lock file is
201           up-to-date. If the lock file is missing, or it needs to be updated,
202           Cargo will exit with an error. The --frozen flag also prevents
203           Cargo from attempting to access the network to determine if it is
204           out-of-date.
205
206           These may be used in environments where you want to assert that the
207           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
208           network access.
209
210       --offline
211           Prevents Cargo from accessing the network for any reason. Without
212           this flag, Cargo will stop with an error if it needs to access the
213           network and the network is not available. With this flag, Cargo
214           will attempt to proceed without the network if possible.
215
216           Beware that this may result in different dependency resolution than
217           online mode. Cargo will restrict itself to crates that are
218           downloaded locally, even if there might be a newer version as
219           indicated in the local copy of the index. See the cargo-fetch(1)
220           command to download dependencies before going offline.
221
222           May also be specified with the net.offline config value
223           <https://doc.rust-lang.org/cargo/reference/config.html>.
224
225   Common Options
226       -h, --help
227           Prints help information.
228
229       -Z FLAG...
230           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
231           details.
232
233   Miscellaneous Options
234       -j N, --jobs N
235           Number of parallel jobs to run. May also be specified with the
236           build.jobs config value
237           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
238           to the number of CPUs.
239

PROFILES

241       Profiles may be used to configure compiler options such as optimization
242       levels and debug settings. See the reference
243       <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
244       for more details.
245
246       Profile selection depends on the target and crate being built. By
247       default the dev or test profiles are used. If the --release flag is
248       given, then the release or bench profiles are used.
249
250       ┌────────────────────┬─────────────────┬───────────────────┐
251       │                    │                 │                   │
252       │Target              │ Default Profile │ --release Profile │
253       ├────────────────────┼─────────────────┼───────────────────┤
254       │                    │                 │                   │
255       │lib, bin, example   │ dev             release           
256       ├────────────────────┼─────────────────┼───────────────────┤
257       │                    │                 │                   │
258       │test, bench, or any │ test            bench             
259       │target              │                 │                   │
260       │in "test" or        │                 │                   │
261       │"bench" mode        │                 │                   │
262       └────────────────────┴─────────────────┴───────────────────┘
263
264       Dependencies use the dev/release profiles.
265

ENVIRONMENT

267       See the reference
268       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
269       for details on environment variables that Cargo reads.
270

EXIT STATUS

272       0
273           Cargo succeeded.
274
275       101
276           Cargo failed to complete.
277

EXAMPLES

279        1. Check the local package for errors:
280
281               cargo check
282
283        2. Check all targets, including unit tests:
284
285               cargo check --all-targets --profile=test
286

SEE ALSO

288       cargo(1), cargo-build(1)
289
290
291
292                                  2019-08-19                    CARGO-CHECK(1)
Impressum