Skip to content

Commit 1228f49

Browse files
committed
Auto merge of #9438 - ehuss:report-subcommand, r=alexcrichton
Add `report` subcommand. This renames the `cargo describe-future-incompatibilities` subcommand to `cargo report future-incompatibilities`. The intent here is to have a general `report` subcommand that can be used for other reports in the future. This helps avoid the proliferation of top-level subcommands, and to help keep the CLI a little more organized.
2 parents db741ac + ff49b82 commit 1228f49

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

src/bin/cargo/commands/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub fn builtin() -> Vec<App> {
77
check::cli(),
88
clean::cli(),
99
config::cli(),
10-
describe_future_incompatibilities::cli(),
1110
doc::cli(),
1211
fetch::cli(),
1312
fix::cli(),
@@ -25,6 +24,7 @@ pub fn builtin() -> Vec<App> {
2524
pkgid::cli(),
2625
publish::cli(),
2726
read_manifest::cli(),
27+
report::cli(),
2828
run::cli(),
2929
rustc::cli(),
3030
rustdoc::cli(),
@@ -47,7 +47,6 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
4747
"check" => check::exec,
4848
"clean" => clean::exec,
4949
"config" => config::exec,
50-
"describe-future-incompatibilities" => describe_future_incompatibilities::exec,
5150
"doc" => doc::exec,
5251
"fetch" => fetch::exec,
5352
"fix" => fix::exec,
@@ -65,6 +64,7 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> Cli
6564
"pkgid" => pkgid::exec,
6665
"publish" => publish::exec,
6766
"read-manifest" => read_manifest::exec,
67+
"report" => report::exec,
6868
"run" => run::exec,
6969
"rustc" => rustc::exec,
7070
"rustdoc" => rustdoc::exec,
@@ -87,7 +87,6 @@ pub mod build;
8787
pub mod check;
8888
pub mod clean;
8989
pub mod config;
90-
pub mod describe_future_incompatibilities;
9190
pub mod doc;
9291
pub mod fetch;
9392
pub mod fix;
@@ -106,6 +105,7 @@ pub mod package;
106105
pub mod pkgid;
107106
pub mod publish;
108107
pub mod read_manifest;
108+
pub mod report;
109109
pub mod run;
110110
pub mod rustc;
111111
pub mod rustdoc;

src/bin/cargo/commands/describe_future_incompatibilities.rs renamed to src/bin/cargo/commands/report.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,35 @@ use cargo::drop_eprint;
55
use std::io::Read;
66

77
pub fn cli() -> App {
8-
subcommand("describe-future-incompatibilities")
9-
.arg(
10-
opt(
11-
"id",
12-
"identifier of the report [generated by a Cargo command invocation",
13-
)
14-
.value_name("id")
15-
.required(true),
8+
subcommand("report")
9+
.about("Generate and display various kinds of reports")
10+
.after_help("Run `cargo help report` for more detailed information.\n")
11+
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
12+
.subcommand(
13+
subcommand("future-incompatibilities")
14+
.about("Reports any crates which will eventually stop compiling")
15+
.arg(
16+
opt(
17+
"id",
18+
"identifier of the report generated by a Cargo command invocation",
19+
)
20+
.value_name("id")
21+
.required(true),
22+
),
1623
)
17-
.about("Reports any crates which will eventually stop compiling")
1824
}
1925

2026
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
2127
if !config.nightly_features_allowed {
22-
return Err(anyhow!(
23-
"`cargo describe-future-incompatibilities` can only be used on the nightly channel"
24-
)
25-
.into());
28+
return Err(anyhow!("`cargo report` can only be used on the nightly channel").into());
2629
}
30+
match args.subcommand() {
31+
("future-incompatibilities", Some(args)) => report_future_incompatibilies(config, args),
32+
(cmd, _) => panic!("unexpected command `{}`", cmd),
33+
}
34+
}
2735

36+
fn report_future_incompatibilies(config: &Config, args: &ArgMatches<'_>) -> CliResult {
2837
let ws = args.workspace(config)?;
2938
let report_file = ws.target_dir().open_ro(
3039
FUTURE_INCOMPAT_FILE,

src/cargo/core/compiler/job_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,11 @@ impl<'cfg> DrainState<'cfg> {
887887
if cx.bcx.build_config.future_incompat_report {
888888
drop_eprint!(cx.bcx.config, "{}", full_report);
889889
drop(cx.bcx.config.shell().note(
890-
&format!("this report can be shown with `cargo describe-future-incompatibilities -Z future-incompat-report --id {}`", id)
890+
&format!("this report can be shown with `cargo report future-incompatibilities -Z future-incompat-report --id {}`", id)
891891
));
892892
} else {
893893
drop(cx.bcx.config.shell().note(
894-
&format!("to see what the problems were, use the option `--future-incompat-report`, or run `cargo describe-future-incompatibilities --id {}`", id)
894+
&format!("to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id {}`", id)
895895
));
896896
}
897897
}

tests/testsuite/future_incompat_report.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ fn gate_future_incompat_report() {
4343
.with_status(101)
4444
.run();
4545

46-
p.cargo("describe-future-incompatibilities --id foo")
47-
.with_stderr_contains(
48-
"error: `cargo describe-future-incompatibilities` can only be used on the nightly channel"
49-
)
46+
p.cargo("report future-incompatibilities --id foo")
47+
.with_stderr_contains("error: `cargo report` can only be used on the nightly channel")
5048
.with_status(101)
5149
.run();
5250
}
@@ -134,7 +132,7 @@ fn test_multi_crate() {
134132
.with_stderr_does_not_contain("[..]triggers[..]")
135133
.run();
136134

137-
p.cargo("describe-future-incompatibilities -Z future-incompat-report --id bad-id")
135+
p.cargo("report future-incompatibilities -Z future-incompat-report --id bad-id")
138136
.masquerade_as_nightly_cargo()
139137
.with_stderr_contains("error: Expected an id of [..]")
140138
.with_stderr_does_not_contain("[..]triggers[..]")
@@ -157,7 +155,7 @@ fn test_multi_crate() {
157155
.unwrap();
158156

159157
// Extract the 'id' from the stdout. We are looking
160-
// for the id in a line of the form "run `cargo describe-future-incompatibilities --id yZ7S`"
158+
// for the id in a line of the form "run `cargo report future-incompatibilities --id yZ7S`"
161159
// which is generated by Cargo to tell the user what command to run
162160
// This is just to test that passing the id suppresses the warning mesasge. Any users needing
163161
// access to the report from a shell script should use the `--future-incompat-report` flag
@@ -172,7 +170,7 @@ fn test_multi_crate() {
172170
// Strip off the trailing '`' included in the output
173171
let id: String = id.chars().take_while(|c| *c != '`').collect();
174172

175-
p.cargo(&format!("describe-future-incompatibilities -Z future-incompat-report --id {}", id))
173+
p.cargo(&format!("report future-incompatibilities -Z future-incompat-report --id {}", id))
176174
.masquerade_as_nightly_cargo()
177175
.with_stderr_contains("The crate `first-dep v0.0.1` currently triggers the following future incompatibility lints:")
178176
.with_stderr_contains("The crate `second-dep v0.0.2` currently triggers the following future incompatibility lints:")

0 commit comments

Comments
 (0)