]> git.proxmox.com Git - rustc.git/blame - src/tools/cargo/src/bin/cargo/commands/check.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / src / tools / cargo / src / bin / cargo / commands / check.rs
CommitLineData
0a29b90c
FG
1use crate::command_prelude::*;
2
3use cargo::ops;
4
5pub fn cli() -> Command {
6 subcommand("check")
7 // subcommand aliases are handled in aliased_command()
8 // .alias("c")
9 .about("Check a local package and all of its dependencies for errors")
add651ee
FG
10 .arg_ignore_rust_version()
11 .arg_future_incompat_report()
12 .arg_message_format()
0a29b90c
FG
13 .arg_quiet()
14 .arg_package_spec(
15 "Package(s) to check",
16 "Check all packages in the workspace",
17 "Exclude packages from the check",
18 )
0a29b90c
FG
19 .arg_targets_all(
20 "Check only this package's library",
21 "Check only the specified binary",
22 "Check all binaries",
23 "Check only the specified example",
24 "Check all examples",
25 "Check only the specified test target",
ed00b5ec 26 "Check all test targets",
0a29b90c 27 "Check only the specified bench target",
ed00b5ec 28 "Check all bench targets",
0a29b90c
FG
29 "Check all targets",
30 )
add651ee 31 .arg_features()
781aab86 32 .arg_parallel()
0a29b90c
FG
33 .arg_release("Check artifacts in release mode, with optimizations")
34 .arg_profile("Check artifacts with the specified profile")
0a29b90c
FG
35 .arg_target_triple("Check for the target triple")
36 .arg_target_dir()
0a29b90c 37 .arg_unit_graph()
0a29b90c 38 .arg_timings()
add651ee 39 .arg_manifest_path()
781aab86
FG
40 .after_help(color_print::cstr!(
41 "Run `<cyan,bold>cargo help check</>` for more detailed information.\n"
42 ))
0a29b90c
FG
43}
44
45pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
46 let ws = args.workspace(config)?;
47 // This is a legacy behavior that causes `cargo check` to pass `--test`.
48 let test = matches!(
49 args.get_one::<String>("profile").map(String::as_str),
50 Some("test")
51 );
52 let mode = CompileMode::Check { test };
53 let compile_opts =
54 args.compile_options(config, mode, Some(&ws), ProfileChecking::LegacyTestOnly)?;
55
56 ops::compile(&ws, &compile_opts)?;
57 Ok(())
58}